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:
@@ -10,7 +10,7 @@ module Producer::Core
|
||||
expect(has_env).to be_a Test
|
||||
end
|
||||
|
||||
describe '#success?' do
|
||||
describe '#verify' do
|
||||
let(:environment) { double('environment') }
|
||||
|
||||
before do
|
||||
@@ -19,22 +19,22 @@ module Producer::Core
|
||||
|
||||
it 'stringifies the queried variable name' do
|
||||
expect(environment).to receive(:has_key?).with(kind_of(String))
|
||||
has_env.success?
|
||||
has_env.verify
|
||||
end
|
||||
|
||||
it 'upcases the queried variable name' do
|
||||
expect(environment).to receive(:has_key?).with('SOME_VARIABLE_NAME')
|
||||
has_env.success?
|
||||
has_env.verify
|
||||
end
|
||||
|
||||
it 'returns true when remote environment var is defined' do
|
||||
allow(environment).to receive(:has_key?) { true }
|
||||
expect(has_env.success?).to be true
|
||||
expect(has_env.verify).to be true
|
||||
end
|
||||
|
||||
it 'returns false when remote environment var is not defined' do
|
||||
allow(environment).to receive(:has_key?) { false }
|
||||
expect(has_env.success?).to be false
|
||||
expect(has_env.verify).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -10,18 +10,18 @@ module Producer::Core
|
||||
expect(has_file).to be_a Test
|
||||
end
|
||||
|
||||
describe '#success?', :ssh do
|
||||
describe '#verify', :ssh do
|
||||
before { sftp_story }
|
||||
|
||||
it 'delegates the call on remote FS' do
|
||||
expect(env.remote.fs).to receive(:has_file?).with(filepath)
|
||||
has_file.success?
|
||||
has_file.verify
|
||||
end
|
||||
|
||||
it 'returns the file existence' do
|
||||
existence = double('existence')
|
||||
allow(env.remote.fs).to receive(:has_file?) { existence }
|
||||
expect(has_file.success?).to be existence
|
||||
expect(has_file.verify).to be existence
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user