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:
@@ -49,6 +49,10 @@ module Producer::Core
|
||||
it 'defines a new test keyword' do
|
||||
expect(dsl).to respond_to :some_test
|
||||
end
|
||||
|
||||
it 'defines the negated test' do
|
||||
expect(dsl).to respond_to :no_some_test
|
||||
end
|
||||
end
|
||||
|
||||
describe '#initialize' do
|
||||
@@ -96,6 +100,16 @@ module Producer::Core
|
||||
dsl.evaluate
|
||||
expect(dsl.tests).to include(some_test)
|
||||
end
|
||||
|
||||
context 'when keyword is prefixed with "no_"' do
|
||||
let(:block) { proc { no_some_test :some, :args } }
|
||||
|
||||
it 'builds a negated test' do
|
||||
expect(some_test_class)
|
||||
.to receive(:new).with(env, :some, :args, negated: true)
|
||||
dsl.evaluate
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user