Skip to content

Commit

Permalink
test: fix database transaction middleware test
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Mar 5, 2021
1 parent 7039806 commit 2e702e1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions spec/lib/rack/pact_broker/database_transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module PactBroker

let(:rack_headers) { {} }

subject { self.send(http_method, "/", rack_headers) }
subject { self.send(http_method, "/", nil, rack_headers) }

it "sets the pactbroker.database_connector on the env" do
actual_env = nil
Expand All @@ -38,17 +38,13 @@ module PactBroker
end

context "when the pactbroker.database_connector already exists" do
let(:rack_headers) { { "pactbroker.database_connector" => double('existing database connector') } }
let(:rack_headers) { { "pactbroker.database_connector" => existing_database_connector } }
let(:existing_database_connector) { double('existing database connector') }

it "does not overwrite it", pending: "key is not showing up in rack env for some reason" do
it "does not overwrite it" do
actual_env = nil
allow(api).to receive(:call) do | env |
actual_env = env
[200, {}, {}]
end
expect(api).to receive(:call).with(hash_including("pactbroker.database_connector" => existing_database_connector)).and_call_original
subject
expect(actual_env["pactbroker.database_connector"]).to be existing_database_connector
end
end

Expand Down

0 comments on commit 2e702e1

Please sign in to comment.