Ashwin Bhaskar

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Mocking HTTPParty response

I am trying to mock/stub a method that returns a http party response. I am not sure if my construction of HTTPParty Response object is correct.

httparty_req = HTTParty::Request.new Net::HTTP::Get, '/'
 response = HTTParty::Response.new(httparty_req, {}, lambda {''}, {:body => edit_valid_attributes})
allow(MyClass).to receive(:find).with(my_data).and_return(response)

But when I try to print the response, it printins an emplty line. The body contains data. Am I constructing the respnse incorrectly?

puts response.class                        //Prints HTTParty::Response
puts response                                 //Prints empty line
puts response.body                       //prints the body
puts response.parsed_response  //Prints empty line