Class: Familia::Validation::CommandExpectation

Inherits:
Object
  • Object
show all
Defined in:
lib/familia/validation/expectations.rb

Overview

Represents an expected Redis command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, args, options = {}) ⇒ CommandExpectation

Returns a new instance of CommandExpectation.



160
161
162
163
164
# File 'lib/familia/validation/expectations.rb', line 160

def initialize(command, args, options = {})
  @command = command.to_s.upcase
  @args = args
  @options = options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



158
159
160
# File 'lib/familia/validation/expectations.rb', line 158

def args
  @args
end

#commandObject (readonly)

Returns the value of attribute command.



158
159
160
# File 'lib/familia/validation/expectations.rb', line 158

def command
  @command
end

#optionsObject (readonly)

Returns the value of attribute options.



158
159
160
# File 'lib/familia/validation/expectations.rb', line 158

def options
  @options
end

Instance Method Details

#matches?(recorded_command) ⇒ Boolean

Returns:

  • (Boolean)


166
167
168
169
170
171
# File 'lib/familia/validation/expectations.rb', line 166

def matches?(recorded_command)
  return false unless command_matches?(recorded_command)
  return false unless args_match?(recorded_command)

  true
end

#to_sObject



173
174
175
176
# File 'lib/familia/validation/expectations.rb', line 173

def to_s
  args_str = @args.map { |arg| format_arg(arg) }.join(', ')
  "#{@command}(#{args_str})"
end