mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
🐼 Added tests for after/before hooks
https://github.com/capistrano/capistrano/issues/1004 The changes of #938 affect the order the task executes. The "prerequisite" task seems to be running as if it was defined in a after block, which makes sense, since it is now invoked by the task instead of being a prerequisite. Since there were missed tests and @juanibiapina added simple tests in #1005, and were modified in this commit to cover current business logic of the master.
This commit is contained in:
parent
486e375692
commit
9da7eb56a0
2 changed files with 76 additions and 0 deletions
|
@ -6,6 +6,9 @@ Reverse Chronological Order:
|
||||||
|
|
||||||
https://github.com/capistrano/capistrano/compare/v3.2.1...HEAD
|
https://github.com/capistrano/capistrano/compare/v3.2.1...HEAD
|
||||||
|
|
||||||
|
* Minor Changes
|
||||||
|
* Added tests for after/before hooks features (@juanibiapina, @miry)
|
||||||
|
|
||||||
## `3.2.1`
|
## `3.2.1`
|
||||||
|
|
||||||
https://github.com/capistrano/capistrano/compare/v3.2.0...v3.2.1
|
https://github.com/capistrano/capistrano/compare/v3.2.0...v3.2.1
|
||||||
|
|
73
spec/lib/capistrano/dsl/task_enhancements_spec.rb
Normal file
73
spec/lib/capistrano/dsl/task_enhancements_spec.rb
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
module Capistrano
|
||||||
|
class DummyTaskEnhancements
|
||||||
|
include TaskEnhancements
|
||||||
|
end
|
||||||
|
|
||||||
|
describe TaskEnhancements do
|
||||||
|
let(:task_enhancements) { DummyTaskEnhancements.new }
|
||||||
|
|
||||||
|
describe 'ordering' do
|
||||||
|
|
||||||
|
after do
|
||||||
|
task.clear
|
||||||
|
before_task.clear
|
||||||
|
after_task.clear
|
||||||
|
Rake::Task.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:order) { [] }
|
||||||
|
let!(:task) do
|
||||||
|
Rake::Task.define_task('task', [:order]) do |t, args|
|
||||||
|
args['order'].push 'task'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
let!(:before_task) do
|
||||||
|
Rake::Task.define_task('before_task') do
|
||||||
|
order.push 'before_task'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
let!(:after_task) do
|
||||||
|
Rake::Task.define_task('after_task') do
|
||||||
|
order.push 'after_task'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'invokes in proper order if define after than before' do
|
||||||
|
task_enhancements.after('task', 'after_task')
|
||||||
|
task_enhancements.before('task', 'before_task')
|
||||||
|
|
||||||
|
Rake::Task['task'].invoke order
|
||||||
|
|
||||||
|
expect(order).to eq(['before_task', 'task', 'after_task'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'invokes in proper order if define before than after' do
|
||||||
|
task_enhancements.before('task', 'before_task')
|
||||||
|
task_enhancements.after('task', 'after_task')
|
||||||
|
|
||||||
|
Rake::Task['task'].invoke order
|
||||||
|
|
||||||
|
expect(order).to eq(['before_task', 'task', 'after_task'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'invokes in proper order and with arguments and block' do
|
||||||
|
task_enhancements.after('task', 'after_task_custom', :order) do |t, args|
|
||||||
|
order.push 'after_task'
|
||||||
|
end
|
||||||
|
|
||||||
|
task_enhancements.before('task', 'before_task_custom', :order) do |t, args|
|
||||||
|
order.push 'before_task'
|
||||||
|
end
|
||||||
|
|
||||||
|
Rake::Task['task'].invoke(order)
|
||||||
|
|
||||||
|
expect(order).to eq(['before_task', 'task', 'after_task'])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue