Class: Dommy::Rails::RSpec::Matchers::HaveXPath
- Inherits:
-
Object
- Object
- Dommy::Rails::RSpec::Matchers::HaveXPath
- Defined in:
- lib/dommy/rails/rspec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expression, text:, count:) ⇒ HaveXPath
constructor
A new instance of HaveXPath.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expression, text:, count:) ⇒ HaveXPath
Returns a new instance of HaveXPath.
163 164 165 166 167 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 163 def initialize(expression, text:, count:) @expression = expression @text = text @count = count end |
Instance Method Details
#description ⇒ Object
178 179 180 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 178 def description "have XPath #{@expression.inspect}" end |
#does_not_match?(actual) ⇒ Boolean
174 175 176 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 174 def does_not_match?(actual) !matches?(actual) end |
#failure_message ⇒ Object
182 183 184 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 182 def "expected to find XPath #{@expression.inspect}, found #{@matched.size}" end |
#failure_message_when_negated ⇒ Object
186 187 188 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 186 def "expected not to find XPath #{@expression.inspect}, found #{@matched.size}" end |
#matches?(actual) ⇒ Boolean
169 170 171 172 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 169 def matches?(actual) @matched = Dommy::Rails::PageInspector.xpath_matches(MatchTarget.document(actual), @expression, text: @text) Dommy::Internal::DomMatching.count_matches?(@matched.size, @count) end |