Class: Dommy::RSpec::Matchers::MatchDomHtml 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(expected_html) ⇒ MatchDomHtml

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 MatchDomHtml.



201
202
203
# File 'lib/dommy/rspec/matchers.rb', line 201

def initialize(expected_html)
  @expected_html = expected_html
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.



216
217
218
# File 'lib/dommy/rspec/matchers.rb', line 216

def description
  "match DOM HTML #{@expected_html.inspect}"
end

#does_not_match?(scope) ⇒ 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)


212
213
214
# File 'lib/dommy/rspec/matchers.rb', line 212

def does_not_match?(scope)
  !matches?(scope)
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.



220
221
222
# File 'lib/dommy/rspec/matchers.rb', line 220

def failure_message
  "expected DOM HTML to match.\nExpected: #{@expected_normalized}\nActual:   #{@actual_normalized}"
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.



224
225
226
# File 'lib/dommy/rspec/matchers.rb', line 224

def failure_message_when_negated
  "expected DOM HTML NOT to match #{@expected_normalized}"
end

#matches?(scope) ⇒ 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)


205
206
207
208
209
210
# File 'lib/dommy/rspec/matchers.rb', line 205

def matches?(scope)
  @scope = Internal::ScopeResolution.resolve(scope)
  @actual_normalized = Internal::DomMatching.normalize_html(Internal::DomMatching.html_of(@scope))
  @expected_normalized = Internal::DomMatching.normalize_html(@expected_html)
  @actual_normalized == @expected_normalized
end