Fabio Rehm 54656151cf Convert specs to RSpec 2.14.8 syntax with Transpec
This conversion is done by Transpec 1.10.2 with the following command:
    transpec test/unit/

* 507 conversions
    from: obj.should
      to: expect(obj).to

* 394 conversions
    from: == expected
      to: eq(expected)

* 260 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 85 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 25 conversions
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

* 19 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 7 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 3 conversions
    from: Klass.any_instance.should_receive(:message)
      to: expect_any_instance_of(Klass).to receive(:message)
2014-03-14 12:02:07 -03:00

66 lines
1.7 KiB
Ruby

require_relative "../../../base"
require Vagrant.source_root.join("plugins/providers/hyperv/provider")
describe VagrantPlugins::HyperV::Provider do
let(:machine) { double("machine") }
let(:platform) { double("platform") }
let(:powershell) { double("powershell") }
subject { described_class.new(machine) }
before do
stub_const("Vagrant::Util::Platform", platform)
stub_const("Vagrant::Util::PowerShell", powershell)
machine.stub(id: "foo")
platform.stub(windows?: true)
platform.stub(windows_admin?: true)
powershell.stub(available?: true)
end
describe "#initialize" do
it "raises an exception if not windows" do
platform.stub(windows?: false)
expect { subject }.
to raise_error(VagrantPlugins::HyperV::Errors::WindowsRequired)
end
it "raises an exception if not an admin" do
platform.stub(windows_admin?: false)
expect { subject }.
to raise_error(VagrantPlugins::HyperV::Errors::AdminRequired)
end
it "raises an exception if powershell is not available" do
powershell.stub(available?: false)
expect { subject }.
to raise_error(VagrantPlugins::HyperV::Errors::PowerShellRequired)
end
end
describe "#driver" do
it "is initialized" do
expect(subject.driver).to be_kind_of(VagrantPlugins::HyperV::Driver)
end
end
describe "#state" do
it "returns not_created if no ID" do
machine.stub(id: nil)
expect(subject.state.id).to eq(:not_created)
end
it "calls an action to determine the ID" do
machine.stub(id: "foo")
expect(machine).to receive(:action).with(:read_state).
and_return({ machine_state_id: :bar })
expect(subject.state.id).to eq(:bar)
end
end
end