Implement `file_append' task action
This commit is contained in:
42
spec/producer/core/actions/file_append_spec.rb
Normal file
42
spec/producer/core/actions/file_append_spec.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
module Actions
|
||||
describe FileAppend, :env do
|
||||
let(:path) { 'some_path' }
|
||||
let(:content) { 'some content' }
|
||||
let(:added_content) { ' added' }
|
||||
subject(:action) { FileAppend.new(env, path, added_content) }
|
||||
|
||||
it_behaves_like 'action'
|
||||
|
||||
before { allow(remote_fs).to receive(:file_read).with(path) { content } }
|
||||
|
||||
describe '#apply' do
|
||||
it 'appends given content to requested file on remote filesystem' do
|
||||
expect(remote_fs)
|
||||
.to receive(:file_write).with(path, action.combined_content)
|
||||
action.apply
|
||||
end
|
||||
end
|
||||
|
||||
describe '#path' do
|
||||
it 'returns the file path' do
|
||||
expect(action.path).to eq path
|
||||
end
|
||||
end
|
||||
|
||||
describe '#content' do
|
||||
it 'returns the content to append' do
|
||||
expect(action.content).to eq added_content
|
||||
end
|
||||
end
|
||||
|
||||
describe '#combined_content' do
|
||||
it 'returns original content and added content combined' do
|
||||
expect(action.combined_content).to eq 'some content added'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -7,7 +7,14 @@ module Producer::Core
|
||||
let(:env) { Env.new }
|
||||
subject(:dsl) { DSL.new(env, &block) }
|
||||
|
||||
%w[echo sh mkdir file_write file_replace_content].each do |action|
|
||||
%w[
|
||||
echo
|
||||
sh
|
||||
mkdir
|
||||
file_append
|
||||
file_replace_content
|
||||
file_write
|
||||
].each do |action|
|
||||
it "has `#{action}' action defined" do
|
||||
expect(dsl).to respond_to action.to_sym
|
||||
end
|
||||
|
Reference in New Issue
Block a user