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 c78d788
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec/models/conversion_host/configurations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c78d788

Please sign in to comment.