Unflatten features directory tree

This commit is contained in:
Thibault Jouan
2014-11-18 11:58:23 +00:00
parent 86a84bbe12
commit 2d3975d47f
36 changed files with 1 additions and 0 deletions

View 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"

View 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"

View 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"

View 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"

View 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"