Class: VariableMatcher
- Includes:
- StringSymbolAdapter
- Defined in:
- lib/extensions/mspec/mspec/matchers/variable.rb
Direct Known Subclasses
HaveClassVariableMatcher, HaveConstantMatcher, HaveInstanceVariableMatcher
Class Attribute Summary collapse
-
.description ⇒ Object
Returns the value of attribute description.
-
.variables_method ⇒ Object
Returns the value of attribute variables_method.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(variable) ⇒ VariableMatcher
constructor
A new instance of VariableMatcher.
- #matches?(object) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods included from StringSymbolAdapter
Constructor Details
#initialize(variable) ⇒ VariableMatcher
Returns a new instance of VariableMatcher.
10 11 12 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 10 def initialize(variable) @variable = convert_name(variable) end |
Class Attribute Details
.description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 7 def description @description end |
.variables_method ⇒ Object
Returns the value of attribute variables_method.
7 8 9 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 7 def variables_method @variables_method end |
Instance Method Details
#failure_message ⇒ Object
19 20 21 22 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 19 def ["Expected #{@object} to have #{self.class.description} '#{@variable}'", "but it does not"] end |
#matches?(object) ⇒ Boolean
14 15 16 17 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 14 def matches?(object) @object = object @object.send(self.class.variables_method).include? @variable end |
#negative_failure_message ⇒ Object
24 25 26 27 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 24 def ["Expected #{@object} NOT to have #{self.class.description} '#{@variable}'", "but it does"] end |