views:

129

answers:

1

I'm working on unit testing an ActiveResource model in my Rails application. I have my ActiveResource::HttpMock code in my test file as follows:

ActiveResource::HttpMock.respond_to do |mock|
  mock.get "/audience/42/people/1.xml", {"Authorization" => "Basic VTExbTJCTzhkZzNMOmFpdU1nbHZJT2taakdPV3A=", "Accept" => "application/xml"}, @some_ivar
end

When I run my test, I get this message:

ActiveResource::InvalidRequestError: No response recorded for <GET: /audiences/42/people.xml?email_address=user%40domain.tld [AuthorizationBasic VTExbTJCTzhkZzNMOmFpdU1nbHZJT2taakdPV3A=Acceptapplication/xml] ()>

I'm sure this is a simple matter of not having my HttpMock configured properly, but at this point I'm unsure how to adjust to make the HttpMock object actually respond to the method call.

(If it's any help, this is related to the StreamSend API's PeopleController. Since this is a third party API endpoint and there isn't a developer sandbox, mocking is really the only way to go on this one I think.)

A: 

Restraining the scope of require 'active_resource/http_mock' fixed this error for me. See this link.

gsmendoza