Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Feb 6, 2020
1 parent 524ec72 commit a497735
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
2 changes: 1 addition & 1 deletion script/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if [ "$RUBY_ENGINE" = "ruby" ]; then
run script/test spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb
fi

BUNDLE_GEMFILE=Gemfile.faraday-0.11 fold "faraday-0.11" \
BUNDLE_GEMFILE=Gemfile.faraday-1.0.0 fold "faraday-1.0.0" \
run script/test spec/lib/vcr/middleware/faraday_spec.rb spec/lib/vcr/library_hooks/faraday_spec.rb \
features/middleware/faraday.feature

Expand Down
28 changes: 3 additions & 25 deletions spec/lib/vcr/library_hooks/faraday_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,23 @@
end

conn.builder.lock!
expect(conn.builder.handlers.last(2).map(&:klass)).to eq([
VCR::Middleware::Faraday,
Faraday::Adapter::NetHttp
])
expect(conn.builder.handlers.last.klass).to eq(VCR::Middleware::Faraday)
end

it 'handles the case where no adapter is declared' do
conn = Faraday.new

conn.builder.lock!
expect(conn.builder.handlers.last(2).map(&:klass)).to eq([
VCR::Middleware::Faraday,
Faraday::Adapter::NetHttp
])
expect(conn.builder.handlers.last.klass).to eq(VCR::Middleware::Faraday)
end

it 'does nothing if the VCR middleware has already been included' do
conn = Faraday.new(:url => 'http://sushi.com') do |builder|
builder.use VCR::Middleware::Faraday
builder.use Faraday::Response::Logger
builder.use Faraday::Adapter::NetHttp
end

conn.builder.lock!
expect(conn.builder.handlers.map(&:klass)).to eq([
VCR::Middleware::Faraday,
Faraday::Response::Logger,
Faraday::Adapter::NetHttp
])
end

it 'prints a warning if the faraday connection stack contains a middleware after the HTTP adapter' do
conn = Faraday.new(:url => 'http://sushi.com') do |builder|
builder.use Faraday::Adapter::NetHttp
builder.use Faraday::Response::Logger
end

expect(conn.builder).to receive(:warn).with(/Faraday::Response::Logger/)
conn.builder.lock!
expect(conn.builder.handlers).to eq([VCR::Middleware::Faraday])
end

it 'gracefully handles the case where there is no explicit HTTP adapter' do
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
require 'simplecov'
SimpleCov.start

require "pry"
require "rspec"
Expand Down

0 comments on commit a497735

Please sign in to comment.