[rspec-users] how to mock a Net::Http object?

Zhenning Guan lists at ruby-forum.com
Tue Mar 2 03:39:03 EST 2010


one_data = Net::HTTP.post_form(URI.parse(country_site), {'country' =>
"american"})
two_data = Net::HTTP.post_form(URI.parse(visit_site), {'country' =>
"english"})

I have a code similar like above code in my application, so how to mock
a a object like above? if only post_from once, I just need to stub
post_form, but now, it has different parameter, how to do it?

Net::HTTP.stub!(:post_form).and_return('my_data')
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list