Displaying 1 result from an estimated 1 matches for "web_stub".
2008 May 03
5
Need some help in reducing my repetions in tests with Mocha
...of code (from http = mock() to Net::HTTP stubs) with only the "with" block changing. But because it is the with block changing, I''m not sure how to create a method which will insert my changing block into the middle of the expectation call.
Well, I have a prototype method:
def web_stub(good=true,&block)
http = mock()
http.stubs(:use_ssl=)
get = http.expects(:get)
if block_given?
get = yield get
end
get.returns(good ? good_response : bad_response)
Net::HTTP.stubs(:new).returns(http)
end
But this requires me to use the very ugly syntax of
web_stub do |get|...