Class: Dommy::RSpec::CapyStyleMatchers::HaveContent Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/rspec/capy_style_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.

Direct Known Subclasses

HaveNoContent

Instance Method Summary collapse

Constructor Details

#initialize(text, **opts) ⇒ HaveContent

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



192
193
194
195
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 192

def initialize(text, **opts)
  @text = text
  @exact = opts[:exact] || opts[:exact_text]
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.



207
208
209
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 207

def description
  "have content #{@text.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)


203
204
205
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 203

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.



211
212
213
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 211

def failure_message
  "expected text to include #{@text.inspect}, got #{@actual.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.



215
216
217
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 215

def failure_message_when_negated
  "expected text NOT to include #{@text.inspect}, got #{@actual.inspect}"
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)


197
198
199
200
201
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 197

def matches?(scope)
  @scope = Internal::ScopeResolution.resolve(scope)
  @actual = Internal::DomMatching.text_of(@scope)
  Internal::DomMatching.text_matches?(@actual, @text, exact: @exact)
end