Use domain double instead of machine

This commit is contained in:
Darragh Bailey
2016-01-26 16:58:17 +00:00
parent c5c15361da
commit c5266a4a25
2 changed files with 9 additions and 8 deletions

View File

@@ -5,14 +5,15 @@ shared_context "libvirt" do
let(:libvirt_context) { true }
let(:id) { "dummy-vagrant_dummy" }
let(:connection) { double("::Fog::Compute") }
let(:connection) { double("connection") }
let(:domain) { double("domain") }
def connection_result(options={})
result = options.fetch(:result, nil)
double("connection_result" => result)
end
before do
before (:each) do
# we don't want unit tests to ever run commands on the system; so we wire
# in a double to ensure any unexpected messages raise exceptions
stub_const("::Fog::Compute", connection)

View File

@@ -15,16 +15,16 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
describe "#call" do
before do
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:get_domain).and_return(machine)
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).
to receive(:get_domain).and_return(domain)
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state).
and_return(:running)
end
context "when machine does not exist" do
before do
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:get_domain).and_return(nil)
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state).
and_return(:not_created)
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).
to receive(:get_domain).and_return(nil)
end
it "raises exception" do
@@ -48,7 +48,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
context "if interrupted waiting for SSH" do
before do
allow(machine).to receive(:wait_for).and_return(true)
allow(domain).to receive(:wait_for).and_return(true)
allow(env).to receive(:[]).and_call_original
allow(env).to receive(:[]).with(:interrupted).and_return(false, true, true)
allow(env).to receive(:[]).with(:ip_address).and_return("192.168.121.2")
@@ -68,7 +68,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
context "when machine boots and ssh available" do
before do
allow(machine).to receive(:wait_for).and_return(true)
allow(domain).to receive(:wait_for).and_return(true)
allow(env).to receive(:[]).and_call_original
allow(env).to receive(:[]).with(:interrupted).and_return(false)
allow(env).to receive(:[]).with(:ip_address).and_return("192.168.121.2")