class Producer::Core::Testing::MockRemote
Public Instance Methods
execute(command, output = '', error_output = '')
click to toggle source
# File lib/producer/core/testing/mock_remote.rb, line 9 def execute command, output = '', error_output = '' program, *args = command.gsub(/\d?>.*/, '').split program_output = command =~ />&2\z/ ? error_output : output send "handle_program_#{program}", args, program_output output end
session()
click to toggle source
# File lib/producer/core/testing/mock_remote.rb, line 5 def session fail RuntimeError, 'no session for mock remote!' end
Private Instance Methods
handle_program_echo(args, output)
click to toggle source
# File lib/producer/core/testing/mock_remote.rb, line 18 def handle_program_echo args, output output << args.join(' ') << "\n" end
handle_program_false(*_)
click to toggle source
# File lib/producer/core/testing/mock_remote.rb, line 26 def handle_program_false *_ fail RemoteCommandExecutionError end
handle_program_true(_, output)
click to toggle source
# File lib/producer/core/testing/mock_remote.rb, line 22 def handle_program_true _, output output << '' end
handle_program_type(args, _)
click to toggle source
# File lib/producer/core/testing/mock_remote.rb, line 30 def handle_program_type args, _ fail RemoteCommandExecutionError unless %w[ echo true false type ].include? args.first end