Class: Dommy::RSpec::Matchers::ContainDom 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(selector, text: nil, count: nil) ⇒ ContainDom

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



53
54
55
56
57
# File 'lib/dommy/rspec/matchers.rb', line 53

def initialize(selector, text: nil, count: nil)
  @selector = selector
  @text = text
  @count = count
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.



69
70
71
72
73
74
# File 'lib/dommy/rspec/matchers.rb', line 69

def description
  parts = ["contain DOM matching #{@selector.inspect}"]
  parts << "with text #{@text.inspect}" if @text
  parts << "(count: #{@count.inspect})" if @count
  parts.join(" ")
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)


65
66
67
# File 'lib/dommy/rspec/matchers.rb', line 65

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.



76
77
78
# File 'lib/dommy/rspec/matchers.rb', line 76

def failure_message
  "expected #{describe_scope} to #{description} (found #{@matched.size})"
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.



80
81
82
# File 'lib/dommy/rspec/matchers.rb', line 80

def failure_message_when_negated
  "expected #{describe_scope} not to #{description} (found #{@matched.size})"
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)


59
60
61
62
63
# File 'lib/dommy/rspec/matchers.rb', line 59

def matches?(scope)
  @scope = Internal::ScopeResolution.resolve(scope)
  @matched = Internal::DomMatching.filter(@scope, @selector, text: @text)
  Internal::DomMatching.count_matches?(@matched.size, @count)
end