diff --git a/spec/models/conversion_host/configurations_spec.rb b/spec/models/conversion_host/configurations_spec.rb index 70095fc55cd..99d70ec7987 100644 --- a/spec/models/conversion_host/configurations_spec.rb +++ b/spec/models/conversion_host/configurations_spec.rb @@ -10,6 +10,9 @@ context "processing configuration requests" do let(:vm) { FactoryGirl.create(:vm) } + before(:each) do + allow(ConversionHost).to receive(:new).and_return(conversion_host) + end context ".enable" do let(:expected_notify) do { @@ -21,14 +24,14 @@ } end it "to succeed and send notification" do - allow_any_instance_of(ConversionHost).to receive(:enable_conversion_host_role) + allow(conversion_host).to receive(:enable_conversion_host_role) expect(Notification).to receive(:create).with(expected_notify) expect(described_class.enable(params)).to be_a(described_class) end it "to fail and send notification" do expected_notify[:type] = :conversion_host_config_failure - allow_any_instance_of(ConversionHost).to receive(:enable_conversion_host_role).and_raise + allow(conversion_host).to receive(:enable_conversion_host_role).and_raise expect(Notification).to receive(:create).with(expected_notify) expect { described_class.enable(params) }.to raise_error(ConversionHost::Configurations::ConfigurationError) end @@ -46,14 +49,14 @@ end it "to succeed and send notification" do - allow_any_instance_of(ConversionHost).to receive(:disable_conversion_host_role) + allow(conversion_host).to receive(:disable_conversion_host_role) expect(Notification).to receive(:create).with(expected_notify) conversion_host.disable end it "to fail and send notification" do expected_notify[:type] = :conversion_host_config_failure - allow_any_instance_of(ConversionHost).to receive(:disable_conversion_host_role).and_raise + allow(conversion_host).to receive(:disable_conversion_host_role).and_raise expect(Notification).to receive(:create).with(expected_notify) expect { conversion_host.disable }.to raise_error(ConversionHost::Configurations::ConfigurationError) end