Class: GLCommand::Matchers::ReturnAttributeMatcher
- Inherits:
-
Object
- Object
- GLCommand::Matchers::ReturnAttributeMatcher
- Defined in:
- lib/gl_command/rspec/matchers.rb
Overview
Specific matcher for ‘returns`, which only stores an Array of keys.
Instance Method Summary collapse
- #being(_expected_type) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attribute) ⇒ ReturnAttributeMatcher
constructor
A new instance of ReturnAttributeMatcher.
- #matches?(command_class) ⇒ Boolean
Constructor Details
#initialize(attribute) ⇒ ReturnAttributeMatcher
Returns a new instance of ReturnAttributeMatcher.
62 63 64 65 |
# File 'lib/gl_command/rspec/matchers.rb', line 62 def initialize(attribute) @attribute = attribute @type_check_attempted = false end |
Instance Method Details
#being(_expected_type) ⇒ Object
67 68 69 70 |
# File 'lib/gl_command/rspec/matchers.rb', line 67 def being(_expected_type) @type_check_attempted = true self end |
#description ⇒ Object
83 84 85 |
# File 'lib/gl_command/rspec/matchers.rb', line 83 def description "return attribute `#{@attribute}`" end |
#failure_message ⇒ Object
87 88 89 90 91 |
# File 'lib/gl_command/rspec/matchers.rb', line 87 def return @failure_reason if @failure_reason "Expected #{@command_class.name} to return `#{@attribute}`" end |
#failure_message_when_negated ⇒ Object
93 94 95 |
# File 'lib/gl_command/rspec/matchers.rb', line 93 def "Expected #{@command_class.name} not to return `#{@attribute}`" end |
#matches?(command_class) ⇒ Boolean
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gl_command/rspec/matchers.rb', line 72 def matches?(command_class) @command_class = command_class.is_a?(Class) ? command_class : command_class.class if @type_check_attempted @failure_reason = 'GLCommand::Callable does not store types for `returns`, so `.being()` cannot be used.' return false end @command_class.returns.include?(@attribute) end |