Class: VariableMatcher
- 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
Constructor Details
#initialize(variable) ⇒ VariableMatcher
Returns a new instance of VariableMatcher.
6 7 8 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 6 def initialize(variable) @variable = variable.to_sym end |
Class Attribute Details
.description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 3 def description @description end |
.variables_method ⇒ Object
Returns the value of attribute variables_method.
3 4 5 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 3 def variables_method @variables_method end |
Instance Method Details
#failure_message ⇒ Object
15 16 17 18 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 15 def ["Expected #{@object} to have #{self.class.description} '#{@variable}'", "but it does not"] end |
#matches?(object) ⇒ Boolean
10 11 12 13 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 10 def matches?(object) @object = object @object.send(self.class.variables_method).include? @variable end |
#negative_failure_message ⇒ Object
20 21 22 23 |
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 20 def ["Expected #{@object} NOT to have #{self.class.description} '#{@variable}'", "but it does"] end |