1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
require "spec_helper"
RSpec.describe Aruba::Platforms::WindowsCommandString do
let(:command_string) { described_class.new(base_command, *arguments) }
let(:cmd_path) { 'C:\Some Path\cmd.exe' }
let(:arguments) { [] }
before do
allow(Aruba.platform).to receive(:which).with("cmd.exe").and_return(cmd_path)
end
describe "#to_a" do
context "with a command with a path" do
let(:base_command) { "C:\\Foo\\Bar" }
it { expect(command_string.to_a).to eq [cmd_path, "/c", base_command] }
end
context "with a command with a path containing spaces" do
let(:base_command) { "C:\\Foo Bar\\Baz" }
it { expect(command_string.to_a).to eq [cmd_path, "/c", 'C:\Foo""" """Bar\Baz'] }
end
context "with a command and arguments" do
let(:base_command) { "C:\\Foo\\Bar" }
let(:arguments) { ["-w", "baz quux"] }
it {
expect(command_string.to_a)
.to eq [cmd_path, "/c", "#{base_command} -w \"baz quux\""]
}
end
end
end
|