Class: Dommy::RSpec::Matchers::HaveDomClass Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/rspec/matchers.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(class_name) ⇒ HaveDomClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of HaveDomClass.



172
173
174
# File 'lib/dommy/rspec/matchers.rb', line 172

def initialize(class_name)
  @class_name = class_name.to_s
end

Instance Method Details

#descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



186
187
188
# File 'lib/dommy/rspec/matchers.rb', line 186

def description
  "have DOM class #{@class_name.inspect}"
end

#does_not_match?(element) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


182
183
184
# File 'lib/dommy/rspec/matchers.rb', line 182

def does_not_match?(element)
  !matches?(element)
end

#failure_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



190
191
192
# File 'lib/dommy/rspec/matchers.rb', line 190

def failure_message
  "expected element to have class #{@class_name.inspect}, got #{@actual_classes.inspect}"
end

#failure_message_when_negatedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



194
195
196
# File 'lib/dommy/rspec/matchers.rb', line 194

def failure_message_when_negated
  "expected element NOT to have class #{@class_name.inspect}, got #{@actual_classes.inspect}"
end

#matches?(element) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


176
177
178
179
180
# File 'lib/dommy/rspec/matchers.rb', line 176

def matches?(element)
  @element = element
  @actual_classes = element.class_list.value.to_s.split(/\s+/)
  @actual_classes.include?(@class_name)
end