0

I have a test, where I test logging.

it "logs out correct messages" do
  resp = stub_request(:post, "https://api.sandbox.ebay.com/identity/v1/oauth2/token").and_return(
                headers: { "Content-Type" => "application/json" },
                body: { access_token: "access_token_value" }.to_json,
              )
  user = create(:user)
  create(:preference, user: user, key: "ebay_refresh_token", string_value: "refresh_token_value")
  expect(Rails.logger).to receive(:info).with(/Access token requested for user##{user.id}/)
  expect(Rails.logger).to receive(:info).with("Response for user##{user.id} access token request received: #{resp.response.inspect}.")
  EbayService.new(user: user).pre_authorize
end

It fails with this error:

  Logger received :info with unexpected arguments  
expected: ("Response for user#15316 access token request received: #<WebMock::Response:0x00007fe19ec99078)
     got: ("Response for user#15316 access token request received: #<HTTParty::Response:0x7fe19dbebac8)

I cannot understand why I keep getting HTTParty::Response instead of WebMock::Response and how can I fix it.

Real http connections are, of course, disabled. Please, point me in the right direction to think.

Dende
  • 545
  • 6
  • 19
  • I don't really get why your code is set up so that it matters in the first place. `# – max Aug 12 '19 at 22:16
  • 1
    I actually log `response.inspect`, however, what is weird and bothers me is why I keep getting `HTTParty::Response` instead of `WebMock::Response` – Dende Aug 13 '19 at 11:36

0 Answers0