Skip to content

Commit

Permalink
Mocked em-http #last_effective_url should return something reasonable
Browse files Browse the repository at this point in the history
  • Loading branch information
samstokes committed Jan 11, 2011
1 parent ed9ff32 commit 0ddd243
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webmock/http_lib_adapters/em_http_request.rb
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions spec/em_http_request_spec.rb
Expand Up @@ -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.