Any success with stubbing Net::HTTP::get?

I found this link the other day, re: how to stub out Net::HTTP::get and
just about flipped it was so cool:
http://habtm.com/articles/2006/01/12/mocking-net-http-get. This is
exactly what I needed and allowed me to right even more happy model
tests.

I made an http.rb in my test/mocks/test directory and added the
suggested require line in my model_test.rb file.

Now, he didn’t give the details on what the fixture should look like.
No matter. I gave it a try anyway.

And when I run ruby test/unit/model_test.rb I’m getting errors from
/usr/lib/ruby/1.8/net/http.rb instead of from my stub file.

I’m calling get from model.rb, naturally, and it (model.rb) has require
‘net/http’. So this seems like a dependency problem. Thoughts?

–dwf

Never mind. User error. I guess I had a hair trigger today.

–dwf

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs