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 6, 2014
1 parent 7731b7a commit a3a9a98
Show file tree
Hide file tree
Showing 2 changed files with 25 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
24 changes: 24 additions & 0 deletions spec/integration/follow_redirects_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require "rspec"
require "faraday"
require "faraday_middleware"
require "webmock/rspec"

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 a3a9a98

Please sign in to comment.