Skip to content

Commit

Permalink
integration test for FollowRedirects
Browse files Browse the repository at this point in the history
initial simple test for the purpose of discussing how we might
want to go about writing integration tests
  • Loading branch information
jjb committed Oct 7, 2014
1 parent c748fa2 commit 6a42194
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group :test do
gem 'cane', '>= 2.2.2', :platforms => [:mri_19, :mri_20, :mri_21]
gem 'rspec', '>= 3'
gem 'simplecov'
gem 'webmock'
end

gemspec
1 change: 1 addition & 0 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def format(result)
end

require 'rspec'
require 'webmock/rspec'
require 'faraday'

module EnvCompatibility
Expand Down
22 changes: 22 additions & 0 deletions spec/integration/follow_redirects_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'helper'
require 'faraday_middleware/response/follow_redirects'

describe FaradayMiddleware::FollowRedirects do
it "redirects" do
stub_request(:get, "http://facebook.com").to_return(
:status => 302,
:headers => { "Location" => "http://www.facebook.com/" })
stub_request(:get, "http://www.facebook.com/").to_return(
:status => 302,
:headers => { "Location" => "https://www.facebook.com/" })
stub_request(:get, "https://www.facebook.com/")

connection = Faraday.new do |conn|
conn.use FaradayMiddleware::FollowRedirects
conn.adapter Faraday.default_adapter
end

response = connection.get "http://facebook.com"
expect(response.env[:url].to_s).to eq("https://www.facebook.com/")
end
end

0 comments on commit 6a42194

Please sign in to comment.