Allow `mkdir' action to work recursively

This commit is contained in:
Thibault Jouan
2014-09-25 20:56:45 +00:00
parent 1e3cd696c8
commit bd66ec25e4
4 changed files with 40 additions and 7 deletions

View File

@@ -9,6 +9,8 @@ module Producer::Core
it_behaves_like 'action'
describe '#apply' do
before { allow(remote_fs).to receive(:dir?) { false } }
it 'creates directory on remote filesystem' do
expect(remote_fs).to receive(:mkdir).with(path)
mkdir.apply
@@ -22,6 +24,25 @@ module Producer::Core
mkdir.apply
end
end
context 'when parent directories does not exists' do
let(:path) { 'some/path' }
it 'creates parent directories' do
expect(remote_fs).to receive(:mkdir).with('some').ordered
expect(remote_fs).to receive(:mkdir).with('some/path').ordered
mkdir.apply
end
end
context 'when directory already exists' do
before { allow(remote_fs).to receive(:dir?) { true } }
it 'creates directory on remote filesystem' do
expect(remote_fs).not_to receive(:mkdir)
mkdir.apply
end
end
end
end
end