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)
90 lines
2.2 KiB
Ruby
90 lines
2.2 KiB
Ruby
require File.expand_path("../../../../base", __FILE__)
|
|
|
|
describe "VagrantPlugins::Shell::Config" do
|
|
let(:described_class) do
|
|
VagrantPlugins::Shell::Plugin.components.configs[:provisioner][:shell]
|
|
end
|
|
|
|
let(:machine) { double('machine', env: Vagrant::Environment.new) }
|
|
let(:file_that_exists) { File.expand_path(__FILE__) }
|
|
|
|
subject { described_class.new }
|
|
|
|
describe "validate" do
|
|
it "passes with no args" do
|
|
subject.path = file_that_exists
|
|
subject.finalize!
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["shell provisioner"]).to eq([])
|
|
end
|
|
|
|
it "passes with string args" do
|
|
subject.path = file_that_exists
|
|
subject.args = "a string"
|
|
subject.finalize!
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["shell provisioner"]).to eq([])
|
|
end
|
|
|
|
it "passes with fixnum args" do
|
|
subject.path = file_that_exists
|
|
subject.args = 1
|
|
subject.finalize!
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["shell provisioner"]).to eq([])
|
|
end
|
|
|
|
it "passes with array args" do
|
|
subject.path = file_that_exists
|
|
subject.args = ["an", "array"]
|
|
subject.finalize!
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["shell provisioner"]).to eq([])
|
|
end
|
|
|
|
it "returns an error if args is neither a string nor an array" do
|
|
neither_array_nor_string = Object.new
|
|
|
|
subject.path = file_that_exists
|
|
subject.args = neither_array_nor_string
|
|
subject.finalize!
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["shell provisioner"]).to eq([
|
|
I18n.t("vagrant.provisioners.shell.args_bad_type")
|
|
])
|
|
end
|
|
|
|
it "handles scalar array args" do
|
|
subject.path = file_that_exists
|
|
subject.args = ["string", 1, 2]
|
|
subject.finalize!
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["shell provisioner"]).to eq([])
|
|
end
|
|
|
|
it "returns an error if args is an array with non-scalar types" do
|
|
subject.path = file_that_exists
|
|
subject.args = [[1]]
|
|
subject.finalize!
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["shell provisioner"]).to eq([
|
|
I18n.t("vagrant.provisioners.shell.args_bad_type")
|
|
])
|
|
end
|
|
end
|
|
end
|