From aa3694b58cffb545fce98f8387e094bdcac3b4cd Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Wed, 5 Mar 2014 07:18:50 +0000 Subject: [PATCH] Add support for `type' command in MockRemote --- lib/producer/core/testing/mock_remote.rb | 7 +++++++ .../producer/core/testing/mock_remote_spec.rb | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/producer/core/testing/mock_remote.rb b/lib/producer/core/testing/mock_remote.rb index e623d90..04f559b 100644 --- a/lib/producer/core/testing/mock_remote.rb +++ b/lib/producer/core/testing/mock_remote.rb @@ -17,6 +17,13 @@ module Producer output << '' when 'false' raise RemoteCommandExecutionError + when 'type' + raise RemoteCommandExecutionError unless %w[ + echo + true + false + type + ].include? tokens.first end output diff --git a/spec/producer/core/testing/mock_remote_spec.rb b/spec/producer/core/testing/mock_remote_spec.rb index 2b5d762..729486d 100644 --- a/spec/producer/core/testing/mock_remote_spec.rb +++ b/spec/producer/core/testing/mock_remote_spec.rb @@ -40,6 +40,25 @@ module Producer::Core expect { remote.execute(command) }.to raise_error(RemoteCommandExecutionError) end end + + context 'dummy type command' do + context 'executable exists' do + let(:command) { 'type true' } + + it 'returns an empty string' do + expect(remote.execute(command)).to eq '' + end + end + + context 'executable does not exist' do + let(:command) { 'type some_non_existent_executable' } + + it 'raises a RemoteCommandExecutionError' do + expect { remote.execute(command) } + .to raise_error(RemoteCommandExecutionError) + end + end + end end end end