producer-core/features/recipe/test_macro.feature
Thibault Jouan feef44b255 Refactor recipe execution in cucumber features
Mock home directory in `run_recipe' helper, avoid the need to use
@mocked_home_directory in many scenarios.
2015-04-06 08:47:46 +00:00

51 lines
1.3 KiB
Gherkin

Feature: `test_macro' recipe keyword
Scenario: declares a new test keyword
Given a recipe with:
"""
test_macro :even? do |n|
n % 2 == 0
end
[1, 2].each do |n|
task "test_macro-even-#{n}" do
condition { even? n }
echo n
end
end
"""
When I successfully execute the recipe
Then the output must contain "2"
And the output must not contain "1"
@sshd
Scenario: has access to core tests
Given a recipe with:
"""
test_macro(:other_env?) { |k| env? k }
[:shell, :non_existent_var].each do |k|
task "test_macro-condition-#{k}" do
condition { other_env? k }
echo "#{k}_ok"
end
end
"""
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"
Scenario: has access to other tests declared with `test_macro'
Given a recipe with:
"""
test_macro(:one?) { |e| e == 1 }
test_macro(:one_alias?) { |e| one? e }
task :test_macro_macro do
condition { one_alias? 1 }
echo 'one_alias_ok'
end
"""
When I successfully execute the recipe
Then the output must contain "one_alias_ok"