class SSHake::Mock::Command
Public Class Methods
new(matcher, &block)
click to toggle source
# File lib/sshake/mock/command.rb, line 9 def initialize(matcher, &block) @matcher = matcher @block = block end
Public Instance Methods
make_response(environment)
click to toggle source
# File lib/sshake/mock/command.rb, line 26 def make_response(environment) response = SSHake::Response.new response.start_time = Time.now @block&.call(response, environment) response.finish_time = Time.now response end
match(command)
click to toggle source
# File lib/sshake/mock/command.rb, line 14 def match(command) command = command.to_s case @matcher when String @matcher == command ? [] : nil when Regexp if match = command.match(/\A#{@matcher}\z/) match.captures end end end