Implement Testing::MockRemote#execute
This commit is contained in:
parent
b576604498
commit
85e3bf2eac
@ -5,6 +5,20 @@ module Producer
|
||||
def session
|
||||
raise 'no session for mock remote!'
|
||||
end
|
||||
|
||||
def execute(command)
|
||||
tokens = command.split
|
||||
program = tokens.shift
|
||||
|
||||
case program
|
||||
when 'echo'
|
||||
tokens.join ' '
|
||||
when 'true'
|
||||
''
|
||||
when 'false'
|
||||
raise RemoteCommandExecutionError
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
require 'spec_helper'
|
||||
require 'producer/core/testing'
|
||||
|
||||
module Producer::Core
|
||||
@ -14,6 +15,32 @@ module Producer::Core
|
||||
expect { remote.session }.to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe '#execute' do
|
||||
context 'dummy echo command' do
|
||||
let(:command) { 'echo some arguments' }
|
||||
|
||||
it 'returns command arguments' do
|
||||
expect(remote.execute(command)).to eq 'some arguments'
|
||||
end
|
||||
end
|
||||
|
||||
context 'dummy true command' do
|
||||
let(:command) { 'true' }
|
||||
|
||||
it 'returns an empty string' do
|
||||
expect(remote.execute(command)).to eq ''
|
||||
end
|
||||
end
|
||||
|
||||
context 'dummy false command' do
|
||||
let(:command) { 'false' }
|
||||
|
||||
it 'raises a RemoteCommandExecutionError' do
|
||||
expect { remote.execute(command) }.to raise_error(RemoteCommandExecutionError)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user