Class: VariableMatcher

Inherits:
Object show all
Defined in:
lib/extensions/mspec/mspec/matchers/variable.rb

Class Attribute Summary collapse

Instance Method Summary collapse

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

.descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 3

def description
  @description
end

.variables_methodObject

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_messageObject



15
16
17
18
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 15

def failure_message
  ["Expected #{@object} to have #{self.class.description} '#{@variable}'",
   "but it does not"]
end

#matches?(object) ⇒ Boolean

Returns:

  • (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_messageObject



20
21
22
23
# File 'lib/extensions/mspec/mspec/matchers/variable.rb', line 20

def negative_failure_message
  ["Expected #{@object} NOT to have #{self.class.description} '#{@variable}'",
   "but it does"]
end