From 1977074f4064bd306e4bd2afea9285007d5dc250 Mon Sep 17 00:00:00 2001 From: James Wong Date: Fri, 16 Nov 2018 09:54:52 -0500 Subject: [PATCH] replace allow_any_instance --- spec/models/conversion_host/configurations_spec.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/models/conversion_host/configurations_spec.rb b/spec/models/conversion_host/configurations_spec.rb index 70095fc55cd..1ba3c198c54 100644 --- a/spec/models/conversion_host/configurations_spec.rb +++ b/spec/models/conversion_host/configurations_spec.rb @@ -21,14 +21,16 @@ } end it "to succeed and send notification" do - allow_any_instance_of(ConversionHost).to receive(:enable_conversion_host_role) + allow(ConversionHost).to receive(:new).and_return(conversion_host) + 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(ConversionHost).to receive(:new).and_return(conversion_host) + 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 +48,16 @@ end it "to succeed and send notification" do - allow_any_instance_of(ConversionHost).to receive(:disable_conversion_host_role) + allow(ConversionHost).to receive(:new).and_return(conversion_host) + 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(ConversionHost).to receive(:new).and_return(conversion_host) + 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