Implement condition DSL negated test prefix (no_*)
* Allow no_* to be used for every tests in condition DSL: condition { no_has_env :shell, '/bin/sh' }; * Modify Test constructor to accept negated: named argument, implement #negated? and #pass?; * Rename #success? to #verify in all test classes.
This commit is contained in:
44
features/tests/negated_test.feature
Normal file
44
features/tests/negated_test.feature
Normal file
@@ -0,0 +1,44 @@
|
||||
@sshd
|
||||
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 { has_env :shell }
|
||||
|
||||
echo 'successful_test'
|
||||
end
|
||||
|
||||
task :negated_test do
|
||||
condition { no_has_env :shell }
|
||||
|
||||
echo 'negated_test'
|
||||
end
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
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 { has_env :inexistent_var }
|
||||
|
||||
echo 'failing_test'
|
||||
end
|
||||
|
||||
task :negated_test do
|
||||
condition { no_has_env :inexistent_var }
|
||||
|
||||
echo 'negated_test'
|
||||
end
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must not contain "failing_test"
|
||||
And the output must contain "negated_test"
|
Reference in New Issue
Block a user