Sha256: dd8cb5ba609e15c9bd61ac0fe617661e96c6e2fb14eee796ead091f8aca4db3a

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

require 'test/helper'
require 'test/stallion'

describe EventMachine::MultiRequest do

  it "should submit multiple requests in parallel and return once all of them are complete" do
    EventMachine.run {
      
      # create an instance of multi-request handler, and the requests themselves
      multi = EventMachine::MultiRequest.new
      
      # add multiple requests to the multi-handler
      multi.add(EventMachine::HttpRequest.new('http://127.0.0.1:8080/').get(:query => {:q => 'test'}))
      multi.add(EventMachine::HttpRequest.new('http://0.0.0.0/').get(:timeout => 1))
      
      multi.callback  {
        # verify successfull request
        multi.responses[:succeeded].size.should == 1
        multi.responses[:succeeded].first.response.should match(/test/)
        
        # verify invalid requests
        multi.responses[:failed].size.should == 1
        multi.responses[:failed].first.response_header.status.should == 0
        
        EventMachine.stop
      }
    } 
  end
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
dwaite-em-http-request-0.1.10 test/test_multi.rb
dwaite-em-http-request-0.1.9 test/test_multi.rb
julien51-em-http-request-0.1.10 test/test_multi.rb
julien51-em-http-request-0.1.11 test/test_multi.rb
julien51-em-http-request-0.1.9 test/test_multi.rb
igrigorik-em-http-request-0.1.8 test/test_multi.rb
astro-em-http-request-0.2.3 test/test_multi.rb
astro-em-http-request-0.2.2 test/test_multi.rb
em-http-request-0.2.2 test/test_multi.rb
em-http-request-0.2.1 test/test_multi.rb
em-http-request-0.2.0 test/test_multi.rb
astro-em-http-request-0.1.15 test/test_multi.rb
astro-em-http-request-0.1.14 test/test_multi.rb
astro-em-http-request-0.1.13 test/test_multi.rb
astro-em-http-request-0.1.12 test/test_multi.rb