From 2e702e1c1d9bcfe6b88f5232e67a209ab84aebb9 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 5 Mar 2021 16:38:02 +1100 Subject: [PATCH] test: fix database transaction middleware test --- .../rack/pact_broker/database_transaction_spec.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/spec/lib/rack/pact_broker/database_transaction_spec.rb b/spec/lib/rack/pact_broker/database_transaction_spec.rb index 5e9a9d281..a0e167b03 100644 --- a/spec/lib/rack/pact_broker/database_transaction_spec.rb +++ b/spec/lib/rack/pact_broker/database_transaction_spec.rb @@ -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 @@ -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