Implement `has_dir' condition keyword

This commit is contained in:
Thibault Jouan
2014-01-21 15:02:07 +00:00
parent 9d7af04d28
commit 0b4df20f55
7 changed files with 69 additions and 1 deletions

View File

@@ -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

View 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