diff --git a/features/cli_verbose.feature b/features/cli_verbose.feature index e21614d..261edd6 100644 --- a/features/cli_verbose.feature +++ b/features/cli_verbose.feature @@ -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:/ diff --git a/lib/producer/core/worker.rb b/lib/producer/core/worker.rb index d57fe0e..37fb92e 100644 --- a/lib/producer/core/worker.rb +++ b/lib/producer/core/worker.rb @@ -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 diff --git a/spec/producer/core/worker_spec.rb b/spec/producer/core/worker_spec.rb index 8ea8aa1..d0d4a30 100644 --- a/spec/producer/core/worker_spec.rb +++ b/spec/producer/core/worker_spec.rb @@ -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