Improve verbose output
This commit is contained in:
parent
519178cb41
commit
44a5b20e14
@ -16,16 +16,18 @@ Feature: CLI verbose option
|
||||
|
||||
Scenario: prints tasks name
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /Task:.+task_ok/
|
||||
Then the output must match /^Task:.+`task_ok'/
|
||||
And the output must match /^Task:.+`task_ko'/
|
||||
|
||||
Scenario: prints whether condition is met
|
||||
Scenario: appends `applying' or `skipped' after tasks name
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /task_ok.+ condition: met.*task_ko.* condition: NOT met/
|
||||
Then the output must match /task_ok.+applying...$/
|
||||
And the output must match /task_ko.+skipped$/
|
||||
|
||||
Scenario: prints actions info
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /task_ok.+ action: echo/
|
||||
Then the output must match /^ action: echo/
|
||||
|
||||
Scenario: formats message with our simple logger
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /\ATask:.+task_ok.*\n.*condition/
|
||||
Then the output must match /\ATask:/
|
||||
|
@ -12,15 +12,14 @@ module Producer
|
||||
end
|
||||
|
||||
def process_task(task)
|
||||
env.log "Task: #{task} applying"
|
||||
if task.condition_met?
|
||||
env.log ' condition: met'
|
||||
env.log "Task: `#{task}' applying..."
|
||||
task.actions.each do |e|
|
||||
env.log " action: #{e} applying"
|
||||
e.apply unless env.dry_run?
|
||||
end
|
||||
else
|
||||
env.log ' condition: NOT met'
|
||||
env.log "Task: `#{task}' skipped"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ module Producer::Core
|
||||
let(:task) { Task.new(task_name, [action]) }
|
||||
|
||||
it 'logs task info' do
|
||||
expect(env).to receive(:log).with /\ATask: #{task_name}/
|
||||
expect(env).to receive(:log).with /\ATask: `#{task_name}'/
|
||||
worker.process_task task
|
||||
end
|
||||
|
||||
@ -28,8 +28,8 @@ module Producer::Core
|
||||
worker.process_task task
|
||||
end
|
||||
|
||||
it 'logs condition info' do
|
||||
expect(env).to receive(:log).with(' condition: met')
|
||||
it 'logs the task as beeing applied' do
|
||||
expect(env).to receive(:log).with /#{task_name}.+applying\.\.\.\z/
|
||||
worker.process_task task
|
||||
end
|
||||
|
||||
@ -56,8 +56,8 @@ module Producer::Core
|
||||
worker.process_task task
|
||||
end
|
||||
|
||||
it 'logs condition info' do
|
||||
expect(env).to receive(:log).with(' condition: NOT met')
|
||||
it 'logs the task as beeing skipped' do
|
||||
expect(env).to receive(:log).with /#{task_name}.+skipped\z/
|
||||
worker.process_task task
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user