Fixed Windows tests to use modern Ruby hash style
This commit is contained in:
parent
59c140ab82
commit
fdb6461af4
|
@ -19,7 +19,7 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
|
|||
|
||||
describe ".ready?" do
|
||||
it "returns true if hostname command executes without error" do
|
||||
expect(shell).to receive(:powershell).with("hostname").and_return({ :exitcode => 0 })
|
||||
expect(shell).to receive(:powershell).with("hostname").and_return({ exitcode: 0 })
|
||||
expect(subject.ready?).to be_true
|
||||
end
|
||||
|
||||
|
@ -38,35 +38,35 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
|
|||
|
||||
describe ".execute" do
|
||||
it "defaults to running in powershell" do
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ :exitcode => 0 })
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ exitcode: 0 })
|
||||
expect(subject.execute("dir")).to eq(0)
|
||||
end
|
||||
|
||||
it "can use cmd shell" do
|
||||
expect(shell).to receive(:cmd).with(kind_of(String)).and_return({ :exitcode => 0 })
|
||||
expect(shell).to receive(:cmd).with(kind_of(String)).and_return({ exitcode: 0 })
|
||||
expect(subject.execute("dir", { :shell => :cmd })).to eq(0)
|
||||
end
|
||||
|
||||
it "raises error when error_check is true and exit code is non-zero" do
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ :exitcode => 1 })
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ exitcode: 1 })
|
||||
expect { subject.execute("dir") }.to raise_error(
|
||||
VagrantPlugins::CommunicatorWinRM::Errors::ExecutionError)
|
||||
end
|
||||
|
||||
it "does not raise error when error_check is false and exit code is non-zero" do
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ :exitcode => 1 })
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ exitcode: 1 })
|
||||
expect(subject.execute("dir", { :error_check => false })).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".test" do
|
||||
it "returns true when exit code is zero" do
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ :exitcode => 0 })
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ exitcode: 0 })
|
||||
expect(subject.test("test -d c:/windows")).to be_true
|
||||
end
|
||||
|
||||
it "returns false when exit code is non-zero" do
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ :exitcode => 1 })
|
||||
expect(shell).to receive(:powershell).with(kind_of(String)).and_return({ exitcode: 1 })
|
||||
expect(subject.test("test -d /tmp/foobar")).to be_false
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
|||
|
||||
describe ".powershell" do
|
||||
it "should call winrm powershell" do
|
||||
expect(session).to receive(:powershell).with("dir").and_return({ :exitcode => 0 })
|
||||
expect(session).to receive(:powershell).with("dir").and_return({ exitcode: 0 })
|
||||
expect(subject.powershell("dir")[:exitcode]).to eq(0)
|
||||
end
|
||||
|
||||
|
@ -36,7 +36,7 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
|||
|
||||
describe ".cmd" do
|
||||
it "should call winrm cmd" do
|
||||
expect(session).to receive(:cmd).with("dir").and_return({ :exitcode => 0 })
|
||||
expect(session).to receive(:cmd).with("dir").and_return({ exitcode: 0 })
|
||||
expect(subject.cmd("dir")[:exitcode]).to eq(0)
|
||||
end
|
||||
end
|
||||
|
@ -50,8 +50,8 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
|||
describe ".endpoint_options" do
|
||||
it "should create endpoint options" do
|
||||
expect(subject.send(:endpoint_options)).to eq(
|
||||
{ :user => "username", :pass => "password", :host => "localhost", :port => 5985,
|
||||
:operation_timeout => 60, :basic_auth_only => true })
|
||||
{ user: "username", pass: "password", host: "localhost", port: 5985,
|
||||
operation_timeout: 60, basic_auth_only: true })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue