Implement `has_dir' condition keyword
This commit is contained in:
@@ -6,7 +6,7 @@ module Producer::Core
|
||||
let(:env) { double 'env' }
|
||||
subject(:dsl) { Condition::DSL.new(env, &block) }
|
||||
|
||||
%w[has_env has_file].each do |test|
|
||||
%w[has_dir has_env has_file].each do |test|
|
||||
it "has `#{test}' test defined" do
|
||||
expect(dsl).to respond_to test.to_sym
|
||||
end
|
||||
|
28
spec/producer/core/tests/has_dir_spec.rb
Normal file
28
spec/producer/core/tests/has_dir_spec.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
describe Tests::HasDir do
|
||||
let(:env) { Env.new }
|
||||
let(:path) { 'some_directory' }
|
||||
subject(:has_dir) { Tests::HasDir.new(env, path) }
|
||||
|
||||
it 'is a kind of test' do
|
||||
expect(has_dir).to be_a Test
|
||||
end
|
||||
|
||||
describe '#verify', :ssh do
|
||||
before { sftp_story }
|
||||
|
||||
it 'delegates the call on remote FS' do
|
||||
expect(env.remote.fs).to receive(:dir?).with(path)
|
||||
has_dir.verify
|
||||
end
|
||||
|
||||
it 'returns the dir existence' do
|
||||
existence = double 'existence'
|
||||
allow(env.remote.fs).to receive(:dir?) { existence }
|
||||
expect(has_dir.verify).to be existence
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user