Home > Blockchain >  Rspec ignore allow block?
Rspec ignore allow block?

Time:11-08

I want to test a rails job which call an endpoint of hubspot API (GET /crm/v3/owners/{ownerId}) and update a record with infos of the request result.

The problem is that I use enter image description here

I try to rtfm on google but I didn't find the solution yet (I'm always bad for rtfm btw)

CodePudding user response:

Ok my CTO finaly gave me the solution by using the Webmock gem

The code snippet :

before do
    stub_request(:get, 'https://api.hubapi.com/crm/v3/owners/876?archived=false&idProperty=id')
      .with(headers: { 'Authorization' => "Bearer #{ENV['HUBSPOT_ACCESS_TOKEN']}" }).to_return(status: 200, body: {
        firstName: 'John',
        lastName: 'Doe'
      }.to_json, headers: {})
  end

  describe '#perform' do
    it 'updates contract' do
      expect { perform }.to change { contract.reload.hubspot_tailor_deal_owner }.from(nil)
                                                                                .to('DOE John')
    end
  end
  • Related