Skip to content
Browse files

Redirects support is only working for em-http-request 1.0.x

  • Loading branch information...
1 parent f86bdde commit 403643047d9224cbec6a79538ce88269babc999b @bblimke committed Sep 9, 2012
Showing with 24 additions and 24 deletions.
  1. +24 −24 spec/acceptance/em_http_request/em_http_request_spec.rb
View
48 spec/acceptance/em_http_request/em_http_request_spec.rb
@@ -11,41 +11,41 @@
include_context "with WebMock", :no_status_message
- context 'when a real request is made and redirects are followed' do
- before { WebMock.allow_net_connect! }
+ #functionality only supported for em-http-request 1.x
+ if defined?(EventMachine::HttpConnection)
+ context 'when a real request is made and redirects are followed' do
+ before { WebMock.allow_net_connect! }
- # This url redirects to the https URL.
- let(:http_url) { "http://raw.github.com:80/gist/fb555cb593f3349d53af/6921dd638337d3f6a51b0e02e7f30e3c414f70d6/vcr_gist" }
- let(:https_url) { http_url.gsub('http', 'https').gsub('80', '443') }
+ # This url redirects to the https URL.
+ let(:http_url) { "http://raw.github.com:80/gist/fb555cb593f3349d53af/6921dd638337d3f6a51b0e02e7f30e3c414f70d6/vcr_gist" }
+ let(:https_url) { http_url.gsub('http', 'https').gsub('80', '443') }
- def make_request
- EM.run do
- request = EM::HttpRequest.new(http_url).get(:redirects => 1)
- request.callback { EM.stop }
+ def make_request
+ EM.run do
+ request = EM::HttpRequest.new(http_url).get(:redirects => 1)
+ request.callback { EM.stop }
+ end
end
- end
- it "invokes the globally_stub_request hook with both requests" do
- urls = []
- WebMock.globally_stub_request { |r| urls << r.uri.to_s; nil }
+ it "invokes the globally_stub_request hook with both requests" do
+ urls = []
+ WebMock.globally_stub_request { |r| urls << r.uri.to_s; nil }
- make_request
+ make_request
- urls.should eq([http_url, https_url])
- end
+ urls.should eq([http_url, https_url])
+ end
- it 'invokes the after_request hook with both requests' do
- urls = []
- WebMock.after_request { |req, res| urls << req.uri.to_s }
+ it 'invokes the after_request hook with both requests' do
+ urls = []
+ WebMock.after_request { |req, res| urls << req.uri.to_s }
- make_request
+ make_request
- urls.should eq([http_url, https_url])
+ urls.should eq([http_url, https_url])
+ end
end
- end
- #functionality only supported for em-http-request 1.x
- if defined?(EventMachine::HttpConnection)
describe "with middleware" do
it "should work with request middleware" do

0 comments on commit 4036430

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