From fdfd5df26f16271c51f09b209a4b9322ba64ee24 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Thu, 9 Oct 2014 20:06:15 +0000 Subject: [PATCH] Fail when `file_replace_content' misses arguments --- lib/producer/core/actions/file_replace_content.rb | 1 + .../producer/core/actions/file_replace_content_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/producer/core/actions/file_replace_content.rb b/lib/producer/core/actions/file_replace_content.rb index 2b4b741..f5a4697 100644 --- a/lib/producer/core/actions/file_replace_content.rb +++ b/lib/producer/core/actions/file_replace_content.rb @@ -3,6 +3,7 @@ module Producer module Actions class FileReplaceContent < Action def setup + check_arguments_size! 3 @path, @pattern, @replacement = arguments end diff --git a/spec/producer/core/actions/file_replace_content_spec.rb b/spec/producer/core/actions/file_replace_content_spec.rb index 74f483f..d4e0052 100644 --- a/spec/producer/core/actions/file_replace_content_spec.rb +++ b/spec/producer/core/actions/file_replace_content_spec.rb @@ -14,6 +14,16 @@ module Producer::Core before { allow(remote_fs).to receive(:file_read).with(path) { content } } + describe '#setup' do + context 'when content is missing' do + let(:replacement) { nil } + + it 'raises ArgumentError' do + expect { action }.to raise_error ArgumentError + end + end + end + describe '#apply' do it 'writes replaced content to file on remote filesystem' do expect(remote_fs)