Skip to content

Commit

Permalink
Fixed Windows tests to use modern Ruby hash style
Browse files Browse the repository at this point in the history
  • Loading branch information
sneal committed Apr 23, 2014
1 parent 59c140a commit fdb6461
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions test/unit/plugins/communicators/winrm/communicator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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

Expand All @@ -38,35 +38,35 @@

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

Expand Down
8 changes: 4 additions & 4 deletions test/unit/plugins/communicators/winrm/shell_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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

Expand All @@ -36,7 +36,7 @@

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
Expand All @@ -50,8 +50,8 @@
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

Expand Down

0 comments on commit fdb6461

Please sign in to comment.