Skip to content

Commit

Permalink
Update tests for faraday 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jul 30, 2022
1 parent b3cf91a commit 37dc417
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ldp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.summary = spec.description
spec.homepage = "https://github.com/projecthydra/ldp"
spec.license = "APACHE2"
spec.required_ruby_version = '~> 2.0'
spec.required_ruby_version = '>= 2.0'

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
Expand Down
32 changes: 22 additions & 10 deletions spec/lib/ldp/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@
builder.adapter :test, conn_stubs do |stub|
end
end
end

let(:auth_conn) do
Faraday.new do |builder|
builder.adapter :test, conn_stubs do |stub|
end
builder.request(:authorization, :basic_auth, 'Aladdin', 'open sesame')
end
end

subject do
Expand Down Expand Up @@ -192,13 +199,15 @@
expect { |b| subject.post "a_container", &b }.to yield_control
end

it "should preserve basic auth headers" do
subject.http.basic_auth('Aladdin', 'open sesame')
subject.post "a_container", 'foo' do |req|
expect(req.headers).to include({ "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" })
context 'with authentication' do
let(:mock_conn) { auth_conn }

it "should preserve basic auth headers" do
subject.post "a_container", 'foo' do |req|
expect(req.headers).to include({ "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" })
end
end
end

end

describe "put" do
Expand Down Expand Up @@ -244,19 +253,22 @@
end
end

it "should preserve basic auth headers" do
subject.http.basic_auth('Aladdin', 'open sesame')
subject.put "a_resource", "some-payload" do |req|
expect(req.headers).to include({ "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" })
context 'with authentication' do
let(:mock_conn) { auth_conn }

it "should preserve basic auth headers" do
subject.put "a_resource", "some-payload" do |req|
expect(req.headers).to include({ "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" })
end
end
end

end

describe 'patch' do
let(:mock_conn) { auth_conn }

it "should preserve basic auth headers" do
subject.http.basic_auth('Aladdin', 'open sesame')
subject.patch "a_container", 'foo' do |req|
expect(req.headers).to include({ "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" })
end
Expand Down

0 comments on commit 37dc417

Please sign in to comment.