Skip to content
Browse files

Mocked em-http #last_effective_url should return something reasonable

  • Loading branch information...
1 parent ed9ff32 commit 0ddd243630c1a3b4c60b9d46c13ff28970b5cf71 @samstokes samstokes committed
Showing with 22 additions and 1 deletion.
  1. +1 −1 lib/webmock/http_lib_adapters/em_http_request.rb
  2. +21 −0 spec/em_http_request_spec.rb
View
2 lib/webmock/http_lib_adapters/em_http_request.rb
@@ -10,7 +10,7 @@ class WebMockHttpRequest < EventMachine::HttpRequest
class WebMockHttpClient < EventMachine::HttpClient
def setup(response, uri, error = nil)
- @uri = uri
+ @last_effective_url = @uri = uri
if error
on_error(error)
fail(self)
View
21 spec/em_http_request_spec.rb
@@ -30,5 +30,26 @@
http_request(:get, "http://www.example.com/?x=3", :query => "a[]=b&a[]=c").body.should == "abc"
end
+ describe "mocking EM::HttpClient API" do
+ before { stub_http_request(:get, "www.example.com/") }
+ subject do
+ client = nil
+ EM.run do
+ client = EventMachine::HttpRequest.new('http://www.example.com/').get
+ client.callback { EM.stop }
+ client.errback { failed }
+ end
+ client
+ end
+
+ it 'should support #uri' do
+ subject.uri.should == Addressable::URI.parse('http://www.example.com/')
+ end
+
+ it 'should support #last_effective_url' do
+ subject.last_effective_url.should == Addressable::URI.parse('http://www.example.com/')
+ end
+ end
+
end
end

0 comments on commit 0ddd243

Please sign in to comment.
Something went wrong with that request. Please try again.