diff --git a/spec/migrations/20190617191109_move_awx_credentials_to_authentications_spec.rb b/spec/migrations/20190617191109_move_awx_credentials_to_authentications_spec.rb index 889c1d2a..0cff1740 100644 --- a/spec/migrations/20190617191109_move_awx_credentials_to_authentications_spec.rb +++ b/spec/migrations/20190617191109_move_awx_credentials_to_authentications_spec.rb @@ -97,7 +97,8 @@ :type => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::VaultCredential" ) expect(auth.manager_ref).to be_nil - expect(described_class).to_not receive(:pg_connection) + allow(PG::Connection).to receive(:new).and_call_original + expect(PG::Connection).to_not receive(:new).with(a_hash_including(:dbname => "awx")) migrate end @@ -108,7 +109,9 @@ :type => "ManageIQ::Providers::AnsibleTower::AutomationManager::GoogleCredential", :manager_ref => "1" ) - expect(described_class).to_not receive(:pg_connection) + + allow(PG::Connection).to receive(:new).and_call_original + expect(PG::Connection).to_not receive(:new).with(a_hash_including(:dbname => "awx")) migrate end @@ -121,14 +124,17 @@ :options => {:become_method => ""}, :manager_ref => "1" ) - expect(described_class).to receive(:pg_connection).and_raise(PG::ConnectionBad) + + allow(PG::Connection).to receive(:new).and_call_original + expect(PG::Connection).to receive(:new).with(a_hash_including(:dbname => "awx")).and_raise(PG::ConnectionBad) migrate end context "with an awx database connection" do before do - allow(described_class).to receive(:pg_connection).with(a_hash_including(:dbname => "awx")).and_return(awx_conn) + allow(PG::Connection).to receive(:new).and_call_original + allow(PG::Connection).to receive(:new).with(a_hash_including(:dbname => "awx")).and_return(awx_conn) end it "removes unwanted data from options when the credential doesn't exist in the awx database" do