Skip to content

Commit

Permalink
Adds spec for calling given block for EventMachine::HttpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Hsu committed Jan 23, 2013
1 parent 2c596fa commit 56dbe82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Expand Up @@ -59,6 +59,7 @@ def send_request(&block)
client.on_error("WebMock timeout error") if webmock_response.should_timeout
client.setup(make_raw_response(webmock_response), @uri,
webmock_response.should_timeout ? "WebMock timeout error" : nil)
block.call(client) unless block.nil?
client
elsif WebMock.net_connect_allowed?(request_signature.uri)
http = super
Expand Down
5 changes: 5 additions & 0 deletions spec/acceptance/em_http_request/em_http_request_spec.rb
Expand Up @@ -205,6 +205,11 @@ def response(resp)
http_request(:post, "http://www.example.com").body.bytesize.should == body.bytesize
end

it "should yield control to given block" do
stub_request(:get, "www.example.com").to_return(:body => "abc")
expect { |b| http_request(:get, "http://www.example.com/", &b) }.to yield_control
end

describe "mocking EM::HttpClient API" do
let(:uri) { "http://www.example.com/" }

Expand Down

0 comments on commit 56dbe82

Please sign in to comment.