Improve config rspec tests

This commit is contained in:
Brian Cain 2018-03-20 15:44:38 -07:00
parent 956ed004bb
commit e7274f1b6c
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
1 changed files with 12 additions and 12 deletions

View File

@ -42,97 +42,97 @@ describe VagrantPlugins::Kernel_V2::TriggerConfig do
describe "creating a before trigger" do
it "creates a trigger with the splat syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.before(:up, hash_block)
bf_trigger = subject.instance_variable_get(:@_before_triggers)
expect(bf_trigger.size).to eq(1)
expect(bf_trigger.first).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger)
end
it "creates a trigger with the array syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.before([:up], hash_block)
bf_trigger = subject.instance_variable_get(:@_before_triggers)
expect(bf_trigger.size).to eq(1)
expect(bf_trigger.first).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger)
end
it "creates a trigger with the block syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.before :up do |trigger|
trigger.name = "rspec"
end
bf_trigger = subject.instance_variable_get(:@_before_triggers)
expect(bf_trigger.size).to eq(1)
expect(bf_trigger.first).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger)
end
it "creates multiple triggers with the splat syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.before(splat, hash_block)
bf_trigger = subject.instance_variable_get(:@_before_triggers)
expect(bf_trigger.size).to eq(3)
bf_trigger.map { |t| expect(t).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger) }
end
it "creates multiple triggers with the block syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.before splat do |trigger|
trigger.name = "rspec"
end
bf_trigger = subject.instance_variable_get(:@_before_triggers)
expect(bf_trigger.size).to eq(3)
bf_trigger.map { |t| expect(t).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger) }
end
it "creates multiple triggers with the array syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.before(arr, hash_block)
bf_trigger = subject.instance_variable_get(:@_before_triggers)
expect(bf_trigger.size).to eq(3)
bf_trigger.map { |t| expect(t).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger) }
end
end
describe "creating an after trigger" do
it "creates a trigger with the splat syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.after(:up, hash_block)
af_trigger = subject.instance_variable_get(:@_after_triggers)
expect(af_trigger.size).to eq(1)
expect(af_trigger.first).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger)
end
it "creates a trigger with the array syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.after([:up], hash_block)
af_trigger = subject.instance_variable_get(:@_after_triggers)
expect(af_trigger.size).to eq(1)
expect(af_trigger.first).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger)
end
it "creates a trigger with the block syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.after :up do |trigger|
trigger.name = "rspec"
end
af_trigger = subject.instance_variable_get(:@_after_triggers)
expect(af_trigger.size).to eq(1)
expect(af_trigger.first).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger)
end
it "creates multiple triggers with the splat syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.after(splat, hash_block)
af_trigger = subject.instance_variable_get(:@_after_triggers)
expect(af_trigger.size).to eq(3)
af_trigger.map { |t| expect(t).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger) }
end
it "creates multiple triggers with the block syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.after splat do |trigger|
trigger.name = "rspec"
end
af_trigger = subject.instance_variable_get(:@_after_triggers)
expect(af_trigger.size).to eq(3)
af_trigger.map { |t| expect(t).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger) }
end
it "creates multiple triggers with the array syntax" do
allow(subject).to receive(:create_trigger).and_return([:foo])
subject.after(arr, hash_block)
af_trigger = subject.instance_variable_get(:@_after_triggers)
expect(af_trigger.size).to eq(3)
af_trigger.map { |t| expect(t).to be_a(VagrantPlugins::Kernel_V2::VagrantConfigTrigger) }
end
end