From ddf584065c3fe96f80fa7038946a2ad743d39b3c Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Tue, 8 Feb 2011 23:39:00 -0500 Subject: [PATCH] update em-http driver to match new interface --- Gemfile | 2 +- em-synchrony.gemspec | 1 - lib/em-synchrony/em-http.rb | 2 +- spec/http_spec.rb | 12 ++++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 7f4f426..04dacaa 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git' group :development do gem 'rspec', '~> 2.0.0' - gem 'em-http-request' + gem 'em-http-request', :git => 'git://github.com/igrigorik/em-http-request' gem 'remcached' gem 'em-mongo' gem 'bson_ext' diff --git a/em-synchrony.gemspec b/em-synchrony.gemspec index 7ba8a91..a6d4b05 100644 --- a/em-synchrony.gemspec +++ b/em-synchrony.gemspec @@ -13,7 +13,6 @@ Gem::Specification.new do |s| s.rubyforge_project = "em-synchrony" - s.required_ruby_version = Gem::Requirement.new(">= 1.9") s.add_runtime_dependency("eventmachine", [">= 0.12.9"]) s.files = `git ls-files`.split("\n") diff --git a/lib/em-synchrony/em-http.rb b/lib/em-synchrony/em-http.rb index f75aa72..763a08f 100644 --- a/lib/em-synchrony/em-http.rb +++ b/lib/em-synchrony/em-http.rb @@ -5,7 +5,7 @@ end module EventMachine - class HttpRequest + module HTTPMethods %w[get head post delete put].each do |type| class_eval %[ alias :a#{type} :#{type} diff --git a/spec/http_spec.rb b/spec/http_spec.rb index 38273dd..9e91fc0 100644 --- a/spec/http_spec.rb +++ b/spec/http_spec.rb @@ -4,6 +4,18 @@ DELAY = 0.25 describe EventMachine::HttpRequest do + it "should perform a synchronous fetch" do + EM.synchrony do + s = StubServer.new("HTTP/1.0 200 OK\r\nConnection: close\r\n\r\nFoo", DELAY) + + r = EventMachine::HttpRequest.new(URL).get + r.response.should == 'Foo' + + s.stop + EventMachine.stop + end + end + it "should fire sequential requests" do EventMachine.synchrony do s = StubServer.new("HTTP/1.0 200 OK\r\nConnection: close\r\n\r\nFoo", DELAY)