I call out to an API, where I then take their xml and parse it to return a Response
object.
Typical stuff for calling a 3rd party API.
So now in my tests I want to use webmock to say "When you get a request to go to example.com, just give me a Response.new object so i can continue on with my code and process it`.
I am using rspec. Here is the code thus far.
Test code is:
stub_request(:any, /.*blah.*/).
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
to_return(:status => 200,
:body => "#{BlahResponse.new("<?xml version=\"1.0\"?><data><type><![CDATA[success]]></type><subject><![CDATA[Info]]></subject><code>29</code><description><![CDATA[Success]]></description><meeting_id><![CDATA[awesome-455]]></meeting_id></data>")}",
:headers => {})
The error always results in response is not a method of Nil, meaning I am not passing anything it looks like.