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

aslak hellesoy aslak.hellesoy at gmail.com
Tue Mar 2 03:49:36 EST 2010


On Tue, Mar 2, 2010 at 9:39 AM, Zhenning Guan <lists at ruby-forum.com> wrote:

> 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?
>
>
http://github.com/blaine/fakeweb

Aslak


> Net::HTTP.stub!(:post_form).and_return('my_data')
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100302/15c85280/attachment.html>


More information about the rspec-users mailing list