Skip to content

Commit

Permalink
Fix tests (#59)
Browse files Browse the repository at this point in the history
Faraday 1.0 has been released and we did a poor job of specifying the dependencies for the faraday tests so the 1.0 upgrade broke the faraday tests. Additionally while fixing this bundler failed to install rails due to resolving to sprockets 4 which requires ruby 2.5.

- Update appraisal to specify faraday ~> 0 for the current tests
- Add tests for faraday 1.0
- Specify a version of sprockets that support all of the versions of ruby that we test on
  • Loading branch information
martin308 authored Jan 9, 2020
1 parent dd025b1 commit c9a3ce1
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 58 deletions.
72 changes: 54 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ gemfiles:
steps:
- ruby:
gemfile: gemfiles/aws_3.gemfile
faraday: &faraday
faraday-zero: &faraday-zero
steps:
- ruby:
gemfile: gemfiles/faraday.gemfile
gemfile: gemfiles/faraday_0.gemfile
faraday-one: &faraday-one
steps:
- ruby:
gemfile: gemfiles/faraday_1.gemfile
sequel-four: &sequel-four
steps:
- ruby:
Expand Down Expand Up @@ -145,17 +149,29 @@ jobs:
aws-three-ruby-two-six:
<<: *aws-three
executor: ruby-two-six
faraday-ruby-two-three:
<<: *faraday
faraday-zero-ruby-two-three:
<<: *faraday-zero
executor: ruby-two-three
faraday-ruby-two-four:
<<: *faraday
faraday-zero-ruby-two-four:
<<: *faraday-zero
executor: ruby-two-four
faraday-ruby-two-five:
<<: *faraday
faraday-zero-ruby-two-five:
<<: *faraday-zero
executor: ruby-two-five
faraday-ruby-two-six:
<<: *faraday
faraday-zero-ruby-two-six:
<<: *faraday-zero
executor: ruby-two-six
faraday-one-ruby-two-three:
<<: *faraday-one
executor: ruby-two-three
faraday-one-ruby-two-four:
<<: *faraday-one
executor: ruby-two-four
faraday-one-ruby-two-five:
<<: *faraday-one
executor: ruby-two-five
faraday-one-ruby-two-six:
<<: *faraday-one
executor: ruby-two-six
sequel-four-ruby-two-three:
<<: *sequel-four
Expand Down Expand Up @@ -339,19 +355,35 @@ workflows:
<<: *tag_filters
requires:
- lint
- faraday-ruby-two-three:
- faraday-zero-ruby-two-three:
<<: *tag_filters
requires:
- lint
- faraday-zero-ruby-two-four:
<<: *tag_filters
requires:
- lint
- faraday-zero-ruby-two-five:
<<: *tag_filters
requires:
- lint
- faraday-zero-ruby-two-six:
<<: *tag_filters
requires:
- lint
- faraday-one-ruby-two-three:
<<: *tag_filters
requires:
- lint
- faraday-ruby-two-four:
- faraday-one-ruby-two-four:
<<: *tag_filters
requires:
- lint
- faraday-ruby-two-five:
- faraday-one-ruby-two-five:
<<: *tag_filters
requires:
- lint
- faraday-ruby-two-six:
- faraday-one-ruby-two-six:
<<: *tag_filters
requires:
- lint
Expand Down Expand Up @@ -543,10 +575,14 @@ workflows:
- aws-three-ruby-two-four
- aws-three-ruby-two-five
- aws-three-ruby-two-six
- faraday-ruby-two-three
- faraday-ruby-two-four
- faraday-ruby-two-five
- faraday-ruby-two-six
- faraday-zero-ruby-two-three
- faraday-zero-ruby-two-four
- faraday-zero-ruby-two-five
- faraday-zero-ruby-two-six
- faraday-one-ruby-two-three
- faraday-one-ruby-two-four
- faraday-one-ruby-two-five
- faraday-one-ruby-two-six
- sequel-four-ruby-two-three
- sequel-four-ruby-two-four
- sequel-four-ruby-two-five
Expand Down
13 changes: 11 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ appraise "aws-3" do
gem "aws-sdk", "~> 3"
end

appraise "faraday" do
gem "faraday"
appraise "faraday-0" do
gem "faraday", "~> 0"
end

appraise "faraday-1" do
gem "faraday", "~> 1"
end

appraise "sequel4" do
Expand All @@ -35,30 +39,35 @@ end
appraise "rails-41" do
gem "rack-test"
gem "rails", "~> 4.1.0"
gem "sprockets", "~> 3"
gem "warden"
end

appraise "rails-42" do
gem "rack-test"
gem "rails", "~> 4.2.0"
gem "sprockets", "~> 3"
gem "warden"
end

appraise "rails-5" do
gem "rack-test"
gem "rails", "~> 5.0.0"
gem "sprockets", "~> 3"
gem "warden"
end

appraise "rails-51" do
gem "rack-test"
gem "rails", "~> 5.1.0"
gem "sprockets", "~> 3"
gem "warden"
end

appraise "rails-52" do
gem "rack-test"
gem "rails", "~> 5.2.0"
gem "sprockets", "~> 3"
gem "warden"
end

Expand Down
7 changes: 7 additions & 0 deletions gemfiles/faraday_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "faraday", "~> 0"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/faraday_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "faraday", "~> 1"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_41.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "rack-test"
gem "rails", "~> 4.1.0"
gem "sprockets", "~> 3"
gem "warden"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_42.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "rack-test"
gem "rails", "~> 4.2.0"
gem "sprockets", "~> 3"
gem "warden"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "rack-test"
gem "rails", "~> 5.0.0"
gem "sprockets", "~> 3"
gem "warden"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_51.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "rack-test"
gem "rails", "~> 5.1.0"
gem "sprockets", "~> 3"
gem "warden"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_52.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "rack-test"
gem "rails", "~> 5.2.0"
gem "sprockets", "~> 3"
gem "warden"

gemspec path: "../"
105 changes: 67 additions & 38 deletions spec/honeycomb/integrations/faraday_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@
end

describe "supports various initialization methods" do
let(:current_faraday_version) { Gem::Version.new(Faraday::VERSION) }
let(:include_http_adapter) do
Gem::Dependency.new("", "~> 0").match?("", current_faraday_version)
end

it "supports standard usage with no block" do
f = Faraday.new("http://honeycomb.io")
expect(f.builder.handlers).to eq([
Faraday::Request::UrlEncoded,
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Faraday::Request::UrlEncoded,
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f.builder.handlers).to eq(expected)
end

it "supports providing a builder with a string key" do
Expand All @@ -53,11 +61,14 @@
end
f = Faraday.new("builder" => stack)

expect(f.builder.handlers).to eq([
Faraday::Request::Retry,
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Faraday::Request::Retry,
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f.builder.handlers).to eq(expected)
end

it "supports providing a builder with a symbol key" do
Expand All @@ -67,11 +78,14 @@
end
f = Faraday.new(builder: stack)

expect(f.builder.handlers).to eq([
Faraday::Request::Retry,
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Faraday::Request::Retry,
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f.builder.handlers).to eq(expected)
end

it "supports providing a builder that only has an adapter" do
Expand All @@ -80,10 +94,13 @@
end
f = Faraday.new(builder: stack)

expect(f.builder.handlers).to eq([
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f.builder.handlers).to eq(expected)
end

it "supports providing a builder and a url" do
Expand All @@ -93,11 +110,14 @@
end
f = Faraday.new("https://example.com", builder: stack)

expect(f.builder.handlers).to eq([
Faraday::Request::Retry,
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Faraday::Request::Retry,
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f.builder.handlers).to eq(expected)
end

it "does not add honeycomb middleware if it is not needed" do
Expand All @@ -108,19 +128,25 @@
# force the builder to lock the middleware stack
f.builder.app

expect(f.builder.handlers).to eq([
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f.builder.handlers).to eq(expected)

f2 = Faraday.new(builder: stack)
# force the builder to lock the middleware stack
f2.builder.app

expect(f2.builder.handlers).to eq([
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f2.builder.handlers).to eq(expected)
end

it "supports providing a builder and a block" do
Expand All @@ -132,12 +158,15 @@
faraday.adapter Faraday.default_adapter
end

expect(f.builder.handlers).to eq([
Faraday::Response::Logger,
Faraday::Request::UrlEncoded,
Honeycomb::Faraday,
Faraday::Adapter::NetHttp,
])
expected = [
Faraday::Response::Logger,
Faraday::Request::UrlEncoded,
Honeycomb::Faraday,
]

include_http_adapter && expected << Faraday::Adapter::NetHttp

expect(f.builder.handlers).to eq(expected)
end
end

Expand Down

0 comments on commit c9a3ce1

Please sign in to comment.