Unflatten features directory tree
This commit is contained in:
29
features/recipe/compose_macro.feature
Normal file
29
features/recipe/compose_macro.feature
Normal file
@@ -0,0 +1,29 @@
|
||||
Feature: `compose_macro' recipe keyword
|
||||
|
||||
Background:
|
||||
Given a recipe named "composed_macro.rb" with:
|
||||
"""
|
||||
macro :hello do |prefix, *args|
|
||||
echo 'hello %s %s' % [prefix, args.join(', ')]
|
||||
end
|
||||
|
||||
compose_macro :hello_composed, :hello, 'composed'
|
||||
"""
|
||||
|
||||
Scenario: declares a composed macro as recipe keyword
|
||||
Given a recipe with:
|
||||
"""
|
||||
source 'composed_macro'
|
||||
hello_composed :foo, :bar
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "hello composed foo, bar"
|
||||
|
||||
Scenario: declares a composed macro as task keyword
|
||||
Given a recipe with:
|
||||
"""
|
||||
source 'composed_macro'
|
||||
task(:some_task) { hello_composed :foo, :bar }
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "hello composed foo, bar"
|
50
features/recipe/macro.feature
Normal file
50
features/recipe/macro.feature
Normal file
@@ -0,0 +1,50 @@
|
||||
Feature: `macro' recipe keyword
|
||||
|
||||
Scenario: declares a new recipe keyword accepting task code
|
||||
Given a recipe with:
|
||||
"""
|
||||
macro :hello do
|
||||
echo 'hello macro'
|
||||
end
|
||||
|
||||
hello
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "hello macro"
|
||||
|
||||
Scenario: declares a new task keyword
|
||||
Given a recipe with:
|
||||
"""
|
||||
macro(:hello) { echo 'hello macro' }
|
||||
|
||||
task(:some_task) { hello }
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "hello macro"
|
||||
|
||||
Scenario: supports arguments
|
||||
Given a recipe with:
|
||||
"""
|
||||
macro :my_echo do |kind, message|
|
||||
echo "#{kind}: #{message}"
|
||||
end
|
||||
|
||||
my_echo 'my', 'hello'
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "my: hello"
|
||||
|
||||
Scenario: supports arguments in conditions
|
||||
Given a recipe with:
|
||||
"""
|
||||
macro :my_echo do |message|
|
||||
condition { message =~ /foo/ }
|
||||
|
||||
echo message
|
||||
end
|
||||
|
||||
%w[foo bar].each { |e| my_echo e }
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "foo"
|
||||
And the output must not contain "bar"
|
17
features/recipe/source.feature
Normal file
17
features/recipe/source.feature
Normal file
@@ -0,0 +1,17 @@
|
||||
Feature: `source' recipe keyword
|
||||
|
||||
Background:
|
||||
Given a recipe with:
|
||||
"""
|
||||
source 'sourced_recipe'
|
||||
"""
|
||||
|
||||
Scenario: requires a recipe file
|
||||
Given a file named "sourced_recipe.rb" with:
|
||||
"""
|
||||
task :some_task do
|
||||
echo 'sourced recipe'
|
||||
end
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "sourced recipe"
|
23
features/recipe/target.feature
Normal file
23
features/recipe/target.feature
Normal file
@@ -0,0 +1,23 @@
|
||||
Feature: `target' recipe keyword
|
||||
|
||||
Scenario: registers the target host on which tasks should be applied
|
||||
Given a recipe with:
|
||||
"""
|
||||
target 'some_host.example'
|
||||
|
||||
task :some_task do
|
||||
echo env.target
|
||||
end
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_host.example"
|
||||
|
||||
Scenario: returns current target when no arguments are provided
|
||||
Given a recipe with:
|
||||
"""
|
||||
target 'some_host.example'
|
||||
|
||||
env.output.puts target
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_host.example"
|
50
features/recipe/test_macro.feature
Normal file
50
features/recipe/test_macro.feature
Normal file
@@ -0,0 +1,50 @@
|
||||
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"
|
Reference in New Issue
Block a user