Class: SSHake::Mock::CommandSet

Inherits:
Object
  • Object
show all
Defined in:
lib/sshake/mock/command_set.rb

Instance Method Summary collapse

Constructor Details

#initializeCommandSet

Returns a new instance of CommandSet.



9
10
11
# File 'lib/sshake/mock/command_set.rb', line 9

def initialize
  @commands = []
end

Instance Method Details

#add(matcher, &block) ⇒ Object



13
14
15
16
17
# File 'lib/sshake/mock/command_set.rb', line 13

def add(matcher, &block)
  command = Command.new(matcher, &block)
  @commands << command
  command
end

#match(given_command) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/sshake/mock/command_set.rb', line 19

def match(given_command)
  @commands.each do |command|
    if matches = command.match(given_command)
      return [command, matches]
    end
  end
  nil
end