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.



184
185
186
187
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 184

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.



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

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)


195
196
197
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 195

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.



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

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.



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

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)


189
190
191
192
193
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 189

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