"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/unit/vagrant/action/builder_test.rb" between
vagrant-2.2.13.tar.gz and vagrant-2.2.14.tar.gz

About: Vagrant provides the framework and configuration format to create and manage complete portable development environments. These development environments can live on your computer or in the cloud, and are portable between Windows, Mac OS X, and Linux.

builder_test.rb  (vagrant-2.2.13):builder_test.rb  (vagrant-2.2.14)
skipping to change at line 258 skipping to change at line 258
hook_proc = proc{ |h| h.append(appender_proc(2)) } hook_proc = proc{ |h| h.append(appender_proc(2)) }
expect(manager).to receive(:action_hooks).with(:test_action). expect(manager).to receive(:action_hooks).with(:test_action).
and_return([hook_proc]) and_return([hook_proc])
data[:action_name] = :test_action data[:action_name] = :test_action
subject.use appender_proc(1) subject.use appender_proc(1)
subject.call(data) subject.call(data)
expect(data[:data]).to eq([1, 2]) expect(data[:data]).to eq([1, 2])
expect(data[:builder_applied]).to eq(:test_action)
end
it "applies without adding action hooks/triggers if it has already" do
hook_proc = proc{ |h| h.append(appender_proc(2)) }
expect(manager).to receive(:action_hooks).with(:test_action).
and_return([hook_proc])
data[:action_name] = :test_action
subject.use appender_proc(1)
subject.call(data.merge(builder_applied: :test_action))
expect(data[:data]).to eq([1])
subject.call(data)
end end
end end
describe "calling another app later" do describe "calling another app later" do
it "calls in the proper order" do it "calls in the proper order" do
# We have to do this because inside the Class.new, it can't see these # We have to do this because inside the Class.new, it can't see these
# rspec methods... # rspec methods...
described_klass = described_class described_klass = described_class
wrapper_proc = self.method(:wrapper_proc) wrapper_proc = self.method(:wrapper_proc)
skipping to change at line 368 skipping to change at line 353
@plugin = nil @plugin = nil
end end
it "should call hook before running action" do it "should call hook before running action" do
instance = described_class.build(ActionTwo) instance = described_class.build(ActionTwo)
instance.call(data) instance.call(data)
expect(data[:data].first).to eq(:first) expect(data[:data].first).to eq(:first)
expect(data[:data].last).to eq(2) expect(data[:data].last).to eq(2)
end end
context "when hook matches action in subsequent builder" do
let(:hook_action_name) { ActionOne }
before do
data[:action_name] = :test_action_name
data[:raw_action_name] = :machine_test_action_name
end
it "should execute the hook" do
described_class.build(ActionTwo).call(data)
described_class.build(ActionOne).call(data)
expect(data[:data]).to include(:first)
end
end
context "when hook matches action name in subsequent builder" do
let(:hook_action_name) { :test_action_name }
before do
data[:action_name] = :test_action_name
data[:raw_action_name] = :machine_test_action_name
end
it "should execute the hook" do
described_class.build(ActionTwo).call(data)
described_class.build(ActionOne).call(data)
expect(data[:data]).to include(:first)
end
it "should execute the hook multiple times" do
described_class.build(ActionTwo).call(data)
described_class.build(ActionOne).call(data)
expect(data[:data].count{|d| d == :first}).to eq(2)
end
end
context "when applying triggers" do
let(:triggers) { double("triggers") }
before do
data[:action_name] = :test_action_name
data[:raw_action_name] = :machine_test_action_name
data[:triggers] = triggers
allow(triggers).to receive(:find).and_return([])
end
it "should attempt to find triggers based on raw action" do
expect(triggers).to receive(:find).with(data[:raw_action_name], any_args
).and_return([])
described_class.build(ActionOne).call(data)
end
it "should only attempt to find triggers based on raw action once" do
expect(triggers).to receive(:find).with(data[:raw_action_name], :before,
any_args).once.and_return([])
expect(triggers).to receive(:find).with(data[:raw_action_name], :after,
any_args).once.and_return([])
described_class.build(ActionOne).call(data)
described_class.build(ActionOne).call(data)
end
end
context "when hook is appending to action" do context "when hook is appending to action" do
let(:plugin) do let(:plugin) do
@plugin ||= Class.new(Vagrant.plugin("2")) do @plugin ||= Class.new(Vagrant.plugin("2")) do
name "Test Plugin" name "Test Plugin"
action_hook(:before_test, :action_two) do |hook| action_hook(:before_test, :action_two) do |hook|
hook.append(proc{ |env| env[:data] << :first }) hook.append(proc{ |env| env[:data] << :first })
end end
end end
end end
 End of changes. 2 change blocks. 
15 lines changed or deleted 62 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)