vaguerent/test/unit/plugins/kernel_v2/config/vm_trigger_test.rb
2018-04-20 10:51:38 -07:00

50 lines
1.1 KiB
Ruby

require File.expand_path("../../../../base", __FILE__)
require Vagrant.source_root.join("plugins/kernel_v2/config/vm_trigger")
describe VagrantPlugins::Kernel_V2::VagrantConfigTrigger do
include_context "unit"
let(:command) { :up }
subject { described_class.new(command) }
let(:machine) { double("machine") }
def assert_invalid
errors = subject.validate(machine)
if !errors.empty? { |v| !v.empty? }
raise "No errors: #{errors.inspect}"
end
end
def assert_valid
errors = subject.validate(machine)
if !errors.empty? { |v| v.empty? }
raise "Errors: #{errors.inspect}"
end
end
before do
env = double("env")
allow(env).to receive(:root_path).and_return(nil)
allow(machine).to receive(:env).and_return(env)
allow(machine).to receive(:provider_config).and_return(nil)
allow(machine).to receive(:provider_options).and_return({})
subject.name = "foo"
end
describe "with defaults" do
it "is valid with test defaults" do
subject.finalize!
assert_valid
end
it "sets a command" do
expect(subject.command).to eq(command)
end
end
end