Skip to content

Commit

Permalink
replace allow_any_instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswnl committed Nov 16, 2018
1 parent 2d2ddfc commit 1977074
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions spec/models/conversion_host/configurations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1977074

Please sign in to comment.