From feef44b255eff58e5d7518811b13412c306942f8 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Mon, 6 Apr 2015 08:47:46 +0000 Subject: [PATCH] Refactor recipe execution in cucumber features Mock home directory in `run_recipe' helper, avoid the need to use @mocked_home_directory in many scenarios. --- features/actions/file_append.feature | 2 +- features/actions/file_replace_content.feature | 2 +- features/actions/file_write.feature | 2 +- features/actions/mkdir.feature | 2 +- features/actions/sh.feature | 2 +- features/actions/yaml_write.feature | 2 +- features/recipe/test_macro.feature | 2 +- lib/producer/core/testing/cucumber/recipe_steps.rb | 4 +++- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/features/actions/file_append.feature b/features/actions/file_append.feature index 09bf541..efefd6a 100644 --- a/features/actions/file_append.feature +++ b/features/actions/file_append.feature @@ -1,4 +1,4 @@ -@sshd @mocked_home_directory +@sshd Feature: `file_append' task action Background: diff --git a/features/actions/file_replace_content.feature b/features/actions/file_replace_content.feature index 36878d0..edaa021 100644 --- a/features/actions/file_replace_content.feature +++ b/features/actions/file_replace_content.feature @@ -1,4 +1,4 @@ -@sshd @mocked_home_directory +@sshd Feature: `file_replace_content' task action Background: diff --git a/features/actions/file_write.feature b/features/actions/file_write.feature index 17c0646..f067dda 100644 --- a/features/actions/file_write.feature +++ b/features/actions/file_write.feature @@ -1,4 +1,4 @@ -@sshd @mocked_home_directory +@sshd Feature: `file_write' task action Background: diff --git a/features/actions/mkdir.feature b/features/actions/mkdir.feature index 5bd5cd2..393ad9b 100644 --- a/features/actions/mkdir.feature +++ b/features/actions/mkdir.feature @@ -1,4 +1,4 @@ -@sshd @mocked_home_directory +@sshd Feature: `mkdir' task action Background: diff --git a/features/actions/sh.feature b/features/actions/sh.feature index 9e5c2ea..eceb3c1 100644 --- a/features/actions/sh.feature +++ b/features/actions/sh.feature @@ -1,4 +1,4 @@ -@sshd @mocked_home_directory +@sshd Feature: `sh' task action Scenario: forwards standard ouput diff --git a/features/actions/yaml_write.feature b/features/actions/yaml_write.feature index 6611ec3..b20371e 100644 --- a/features/actions/yaml_write.feature +++ b/features/actions/yaml_write.feature @@ -1,4 +1,4 @@ -@sshd @mocked_home_directory +@sshd Feature: `yaml_write' task action Background: diff --git a/features/recipe/test_macro.feature b/features/recipe/test_macro.feature index c9b000b..c426b16 100644 --- a/features/recipe/test_macro.feature +++ b/features/recipe/test_macro.feature @@ -18,7 +18,7 @@ Feature: `test_macro' recipe keyword Then the output must contain "2" And the output must not contain "1" - @sshd @mocked_home_directory + @sshd Scenario: has access to core tests Given a recipe with: """ diff --git a/lib/producer/core/testing/cucumber/recipe_steps.rb b/lib/producer/core/testing/cucumber/recipe_steps.rb index 6d79cc9..c1136c3 100644 --- a/lib/producer/core/testing/cucumber/recipe_steps.rb +++ b/lib/producer/core/testing/cucumber/recipe_steps.rb @@ -7,7 +7,9 @@ def run_recipe(remote: false, options: nil, check: false, rargv: nil) command << options if options command << ['--', *rargv] if rargv - run_simple command.join(' '), false + with_env 'HOME' => File.expand_path(current_dir) do + run_simple command.join(' '), false + end assert_exit_status 0 if check assert_matching_output '\ASocketError', all_output if remote == :unknown