Class: Dommy::Rails::RSpec::Matchers::HaveLink
- Inherits:
-
Object
- Object
- Dommy::Rails::RSpec::Matchers::HaveLink
- 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(text, href:, count:) ⇒ HaveLink
constructor
A new instance of HaveLink.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(text, href:, count:) ⇒ HaveLink
Returns a new instance of HaveLink.
331 332 333 334 335 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 331 def initialize(text, href:, count:) @text = text @href = href @count = count end |
Instance Method Details
#description ⇒ Object
346 347 348 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 346 def description "have link" end |
#does_not_match?(actual) ⇒ Boolean
342 343 344 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 342 def does_not_match?(actual) !matches?(actual) end |
#failure_message ⇒ Object
350 351 352 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 350 def "expected to find link, found #{@matched.size}" end |
#failure_message_when_negated ⇒ Object
354 355 356 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 354 def "expected not to find link, found #{@matched.size}" end |
#matches?(actual) ⇒ Boolean
337 338 339 340 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 337 def matches?(actual) @matched = Dommy::Rails::PageInspector.links(MatchTarget.document(actual), text: @text, href: @href) Dommy::Internal::DomMatching.count_matches?(@matched.size, @count) end |