Class: Familia::Validation::CommandExpectation
- Inherits:
-
Object
- Object
- Familia::Validation::CommandExpectation
- Defined in:
- lib/familia/validation/expectations.rb
Overview
Represents an expected Redis command
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(command, args, options = {}) ⇒ CommandExpectation
constructor
A new instance of CommandExpectation.
-
#matches?(recorded_command) ⇒ Boolean
-
#to_s ⇒ Object
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, = {}) @command = command.to_s.upcase @args = args @options = end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
158 159 160 |
# File 'lib/familia/validation/expectations.rb', line 158 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
158 159 160 |
# File 'lib/familia/validation/expectations.rb', line 158 def command @command end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
158 159 160 |
# File 'lib/familia/validation/expectations.rb', line 158 def @options end |
Instance Method Details
#matches?(recorded_command) ⇒ 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_s ⇒ Object
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 |