Permalink
Browse files

Use provided hydra.

  • Loading branch information...
1 parent 4760ad8 commit 44988161d4bc7d1509be19ca78575eb7161f3fe8 @i0rek committed Aug 23, 2012
Showing with 18 additions and 13 deletions.
  1. +18 −13 spec/acceptance/typhoeus/typhoeus_hydra_spec.rb
View
31 spec/acceptance/typhoeus/typhoeus_hydra_spec.rb
@@ -22,29 +22,34 @@
describe "when params are used" do
it "should take into account params for POST request" do
- stub_request(:post, "www.example.com").with(:body => {:hello => 'world'})
- Typhoeus::Request.post("www.example.com", :params => {:hello => 'world'})
+ stub_request(:post, "www.example.com").with(:params => {:hello => 'world'})
+ request = Typhoeus::Request.new("http://www.example.com", :method => :post, :params => {:hello => 'world'})
+ hydra.queue(request)
+ hydra.run
end
it "should take into account params for GET request" do
- stub_request(:get, "http://www.example.com/?hello=world")
- Typhoeus::Request.get("www.example.com", :params => {:hello => 'world'})
+ stub_request(:get, "http://www.example.com/?hello=world").to_return({})
+ request = Typhoeus::Request.new("http://www.example.com/?hello=world", :method => :get)
+ hydra.queue(request)
+ hydra.run
end
end
describe "timeouts" do
it "should support native typhoeus timeouts" do
stub_request(:any, "example.com").to_timeout
- response = Typhoeus::Request.get("http://example.com")
+ request = Typhoeus::Request.new("http://example.com", :method => :get)
+ hydra.queue(request)
+ hydra.run
- response.should be_timed_out
+ request.response.should be_timed_out
end
end
describe "callbacks" do
before(:each) do
- @hydra = Typhoeus::Hydra.new
@request = Typhoeus::Request.new("http://example.com")
end
@@ -53,11 +58,11 @@
stub_request(:any, "example.com").to_return(:body => body)
test = nil
- @hydra.on_complete do |c|
+ Typhoeus.on_complete do |c|
test = c.body
end
- @hydra.queue @request
- @hydra.run
+ hydra.queue @request
+ hydra.run
test.should == body
end
@@ -66,11 +71,11 @@
stub_request(:any, "example.com").to_return(:status => [response_code, "Server On Fire"])
test = nil
- @hydra.on_complete do |c|
+ Typhoeus.on_complete do |c|
test = c.code
end
- @hydra.queue @request
- @hydra.run
+ hydra.queue @request
+ hydra.run
test.should == response_code
end
end

0 comments on commit 4498816

Please sign in to comment.