Class: Utensils::CustomMatchers::HaveClass

Inherits:
Object
  • Object
show all
Defined in:
lib/utensils/custom_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(class_name) ⇒ HaveClass

Returns a new instance of HaveClass.



27
28
29
# File 'lib/utensils/custom_matchers.rb', line 27

def initialize(class_name)
  @class_name = class_name
end

Instance Method Details

#failure_messageObject



36
37
38
# File 'lib/utensils/custom_matchers.rb', line 36

def failure_message
  "expected #{@element.tag_name} to have class #{@class_name} but had #{@element[:class]}"
end

#failure_message_when_negatedObject



40
41
42
# File 'lib/utensils/custom_matchers.rb', line 40

def failure_message_when_negated
  "expected #{@element.tag_name} to not have class #{@class_name} but it did"
end

#matches?(element) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/utensils/custom_matchers.rb', line 31

def matches?(element)
  @element = element
  @element[:class] == @class_name
end