end of file reached with webmock/minitest 1.8.9 gem #207

Closed
epinault opened this Issue Aug 21, 2012 · 2 comments

Comments

Projects
None yet
2 participants

I am using ruby 1.9.2, and I have a pretty simple stub

stub_request(:get, /gadgets.json/).to_return("['toto','tiit']")

yet I get. No clue what is wrong now. Something in web mock but don t make any sense

ERROR test_0017_should return the correct list of gadgets (0.00s)
end of file reached
/home/emmanuel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:135:in read_nonblock' /home/emmanuel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:135:inrbuf_fill'
/home/emmanuel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:116:in readuntil' /home/emmanuel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:126:inreadline'
/home/emmanuel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:2219:in read_status_line' /home/emmanuel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:2208:inread_new'
/home/emmanuel/talemetry/talemetry_common_lib/primeshare/vendor/ruby/1.9.1/gems/webmock-1.8.9/lib/webmock/response.rb:117:in read_raw_response' /home/emmanuel/talemetry/talemetry_common_lib/primeshare/vendor/ruby/1.9.1/gems/webmock-1.8.9/lib/webmock/response.rb:21:ininitialize'
/home/emmanuel/talemetry/talemetry_common_lib/primeshare/vendor/ruby/1.9.1/gems/webmock-1.8.9/lib/webmock/response.rb:13:in new' /home/emmanuel/talemetry/talemetry_common_lib/primeshare/vendor/ruby/1.9.1/gems/webmock-1.8.9/lib/webmock/response.rb:13:inresponse_for'
/home/emmanuel/talemetry/talemetry_common_lib/primeshare/vendor/ruby/1.9.1/gems/webmock-1.8.9/lib/webmock/request_stub.rb:21:in block in to_return' /home/emmanuel/talemetry/talemetry_common_lib/primeshare/vendor/ruby/1.9.1/gems/webmock-1.8.9/lib/webmock/request_stub.rb:21:inmap'
/home/emmanuel/talemetry/talemetry_common_lib/primeshare/vendor/ruby/1.9.1/gems/webmock-1.8.9/lib/webmock/request_stub.rb:21:in `to_return'

Owner

bblimke commented Aug 21, 2012

If you pass a string as an argument to to_return it has to be a raw response string.

I guess you just want to declare a response body, then you should use:
stub_request(:get, /gadgets.json/).to_return(:body => "['toto','tiit']")

@bblimke bblimke closed this Aug 21, 2012

Ah ! I see I got confused between that and passing a file . Sorry for the noise. All thos mock library work slightly differently with method name close (and_returns vs to_return ).. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment