From a033e19583ca61a104f610438945a8e6a50e8f12 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 18 Jul 2014 12:23:17 +0000 Subject: [PATCH] Refactor features --- features/action_file_append.feature | 4 +--- features/action_file_replace_content.feature | 6 ++---- features/action_file_write.feature | 6 ++---- features/action_mkdir.feature | 6 ++---- features/action_sh.feature | 12 +++--------- features/cli_target.feature | 2 +- features/recipe_test_macro.feature | 4 +--- features/steps/recipe_steps.rb | 9 +++++++++ features/test_dir.feature | 6 ++---- features/test_env.feature | 10 ++++------ features/test_executable.feature | 6 ++---- features/test_file.feature | 6 ++---- features/test_file_contains.feature | 8 +++----- features/test_negated_test.feature | 8 ++------ features/test_shell_command_status.feature | 10 ++++------ 15 files changed, 40 insertions(+), 63 deletions(-) diff --git a/features/action_file_append.feature b/features/action_file_append.feature index 7cb20ec..efefd6a 100644 --- a/features/action_file_append.feature +++ b/features/action_file_append.feature @@ -7,11 +7,9 @@ Feature: `file_append' task action Scenario: appends given content to requested file Given a recipe with: """ - target 'some_host.test' - task :file_append_action do file_append 'some_file', ' added' end """ - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the remote file "some_file" must contain exactly "some content added" diff --git a/features/action_file_replace_content.feature b/features/action_file_replace_content.feature index c1b15f8..edaa021 100644 --- a/features/action_file_replace_content.feature +++ b/features/action_file_replace_content.feature @@ -6,8 +6,6 @@ Feature: `file_replace_content' task action And a remote file named "other_file" with "some content" And a recipe with: """ - target 'some_host.test' - task :file_replace_content_action_string do file_replace_content 'some_file', 'content', 'other content' end @@ -18,9 +16,9 @@ Feature: `file_replace_content' task action """ Scenario: replaces a string by another in the requested file - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the remote file "some_file" must contain exactly "some other content" Scenario: replaces a regular expression by a string in the requested file - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the remote file "other_file" must contain exactly "some other content" diff --git a/features/action_file_write.feature b/features/action_file_write.feature index 20f9f50..e099215 100644 --- a/features/action_file_write.feature +++ b/features/action_file_write.feature @@ -4,8 +4,6 @@ Feature: `file_write' task action Background: Given a recipe with: """ - target 'some_host.test' - task :file_write_action do file_write 'some_file', 'some_content' file_write 'some_file_0600', 'some_content', 0600 @@ -14,10 +12,10 @@ Feature: `file_write' task action """ Scenario: writes given data to given file path - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the remote file "some_file" must contain "some_content" Scenario: creates file with given permissions - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the remote file "some_file_0600" must have 0600 mode And the remote file "some_file_0700" must have 0700 mode diff --git a/features/action_mkdir.feature b/features/action_mkdir.feature index e6596ef..241edb5 100644 --- a/features/action_mkdir.feature +++ b/features/action_mkdir.feature @@ -4,8 +4,6 @@ Feature: `mkdir' task action Background: Given a recipe with: """ - target 'some_host.test' - task :mkdir_action do mkdir 'some_directory' mkdir 'some_directory_0700', 0700 @@ -14,10 +12,10 @@ Feature: `mkdir' task action """ Scenario: creates directory given as argument - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the remote directory "some_directory" must exists Scenario: creates directory with given permissions - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the remote directory "some_directory_0700" must have 0700 mode And the remote directory "some_directory_0500" must have 0500 mode diff --git a/features/action_sh.feature b/features/action_sh.feature index 84fc067..79352bf 100644 --- a/features/action_sh.feature +++ b/features/action_sh.feature @@ -4,36 +4,30 @@ Feature: `sh' task action Scenario: forwards standard ouput Given a recipe with: """ - target 'some_host.test' - task :sh_action do sh '\echo hello from remote' end """ - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain exactly "hello from remote\n" Scenario: aborts on failed command execution Given a recipe with: """ - target 'some_host.test' - task :sh_action_aborting do sh '\false' sh '\echo after_fail' end """ - When I execute the recipe + When I execute the recipe on remote target Then the output must not contain "after_fail" Scenario: prints command when execution fail Given a recipe with: """ - target 'some_host.test' - task :sh_action_command_error do sh '\false' end """ - When I execute the recipe + When I execute the recipe on remote target Then the output must match /\A\w+Error:\s+\\false/ diff --git a/features/cli_target.feature b/features/cli_target.feature index a3eadf7..5973039 100644 --- a/features/cli_target.feature +++ b/features/cli_target.feature @@ -10,6 +10,6 @@ Feature: CLI target option end """ - Scenario: prints tasks name + Scenario: override the recipe target When I successfully execute the recipe with option -t other_host.example Then the output must contain exactly "other_host.example\n" diff --git a/features/recipe_test_macro.feature b/features/recipe_test_macro.feature index 03e5f55..c426b16 100644 --- a/features/recipe_test_macro.feature +++ b/features/recipe_test_macro.feature @@ -22,8 +22,6 @@ Feature: `test_macro' recipe keyword Scenario: has access to core tests Given a recipe with: """ - target 'some_host.test' - test_macro(:other_env?) { |k| env? k } [:shell, :non_existent_var].each do |k| @@ -33,7 +31,7 @@ Feature: `test_macro' recipe keyword end end """ - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "shell_ok" Then the output must not contain "non_existent_var_ok" diff --git a/features/steps/recipe_steps.rb b/features/steps/recipe_steps.rb index ea40502..a0fcdf8 100644 --- a/features/steps/recipe_steps.rb +++ b/features/steps/recipe_steps.rb @@ -6,11 +6,20 @@ When /^I execute the recipe$/ do run_simple 'producer recipe.rb', false end +When /^I execute the recipe on remote target$/ do + run_simple 'producer recipe.rb -t some_host.test', false +end + When /^I successfully execute the recipe$/ do step 'I execute the recipe' assert_exit_status 0 end +When /^I successfully execute the recipe on remote target$/ do + step 'I execute the recipe on remote target' + assert_exit_status 0 +end + When /^I successfully execute the recipe with option (-.+)$/ do |option| run_simple "producer #{option} recipe.rb", false assert_exit_status 0 diff --git a/features/test_dir.feature b/features/test_dir.feature index 82c188e..8f680eb 100644 --- a/features/test_dir.feature +++ b/features/test_dir.feature @@ -4,8 +4,6 @@ Feature: `dir?' condition keyword Background: Given a recipe with: """ - target 'some_host.test' - task :dir_test do condition { dir? 'some_directory' } @@ -15,9 +13,9 @@ Feature: `dir?' condition keyword Scenario: succeeds when directory exists Given a remote directory named "some_directory" - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "evaluated" Scenario: fails when directory does not exist - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "evaluated" diff --git a/features/test_env.feature b/features/test_env.feature index 9943dc2..5d9ca54 100644 --- a/features/test_env.feature +++ b/features/test_env.feature @@ -4,8 +4,6 @@ Feature: `env?' condition keyword Background: Given a recipe with: """ - target 'some_host.test' - task :env_test_definition_ok do condition { env? :shell } @@ -32,17 +30,17 @@ Feature: `env?' condition keyword """ Scenario: succeeds when remote environment variable is defined - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "definition_ok" Scenario: fails when remote environment variable is not defined - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "definition_ko" Scenario: succeeds when remote environment variable value match - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "value_ok" Scenario: fails when remote environment variable value does not match - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "value_ko" diff --git a/features/test_executable.feature b/features/test_executable.feature index b9363be..fb666d6 100644 --- a/features/test_executable.feature +++ b/features/test_executable.feature @@ -4,8 +4,6 @@ Feature: `executable?' condition keyword Background: Given a recipe with: """ - target 'some_host.test' - task :executable_test_ok do condition { executable? 'true' } @@ -20,9 +18,9 @@ Feature: `executable?' condition keyword """ Scenario: succeeds when remote executable is available - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "test_ok" Scenario: fails when remote executable is not available - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "test_ko" diff --git a/features/test_file.feature b/features/test_file.feature index 82fd0d5..5483692 100644 --- a/features/test_file.feature +++ b/features/test_file.feature @@ -4,8 +4,6 @@ Feature: `file?' condition keyword Background: Given a recipe with: """ - target 'some_host.test' - task :file_test do condition { file? 'some_file' } @@ -15,9 +13,9 @@ Feature: `file?' condition keyword Scenario: succeeds when file exists Given a remote file named "some_file" - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "evaluated" Scenario: fails when file does not exist - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "evaluated" diff --git a/features/test_file_contains.feature b/features/test_file_contains.feature index d51f5af..7763109 100644 --- a/features/test_file_contains.feature +++ b/features/test_file_contains.feature @@ -4,8 +4,6 @@ Feature: `file_contains' condition keyword Background: Given a recipe with: """ - target 'some_host.test' - task :file_contains_test do condition { file_contains 'some_file', 'some_content' } @@ -15,14 +13,14 @@ Feature: `file_contains' condition keyword Scenario: succeeds when file contains expected content Given a remote file named "some_file" with "some_content" - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "evaluated" Scenario: fails when file does not contain expected content Given a remote file named "some_file" with "some_other_content" - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "evaluated" Scenario: fails when file does not exist - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "evaluated" diff --git a/features/test_negated_test.feature b/features/test_negated_test.feature index bd30493..4ebbba8 100644 --- a/features/test_negated_test.feature +++ b/features/test_negated_test.feature @@ -4,8 +4,6 @@ Feature: negated test prefix (no_) Scenario: prefixed test fails when non-prefixed test is successful Given a recipe with: """ - target 'some_host.test' - task :successful_test do condition { env? :shell } @@ -18,15 +16,13 @@ Feature: negated test prefix (no_) echo 'negated_test' end """ - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "successful_test" And the output must not contain "negated_test" Scenario: prefixed test fails when non-prefixed test is failing Given a recipe with: """ - target 'some_host.test' - task :failing_test do condition { env? :inexistent_var } @@ -39,6 +35,6 @@ Feature: negated test prefix (no_) echo 'negated_test' end """ - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "failing_test" And the output must contain "negated_test" diff --git a/features/test_shell_command_status.feature b/features/test_shell_command_status.feature index a861cc4..657a000 100644 --- a/features/test_shell_command_status.feature +++ b/features/test_shell_command_status.feature @@ -4,8 +4,6 @@ Feature: `sh' and `` condition keyword Background: Given a recipe with: """ - target 'some_host.test' - task :sh_test_ok do condition { sh 'true' } @@ -32,17 +30,17 @@ Feature: `sh' and `` condition keyword """ Scenario: succeeds when remote command execution is a success - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "test_ok" Scenario: fails when remote executable is not available - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "test_ko" Scenario: `` alias, succeeds when remote executable is available - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must contain "test_backtick_ok" Scenario: `` alias, fails when remote executable is not available - When I successfully execute the recipe + When I successfully execute the recipe on remote target Then the output must not contain "test_backtick_ko"