Class: Dommy::Rails::RSpec::Matchers::HaveHtmlLink
- Inherits:
-
Object
- Object
- Dommy::Rails::RSpec::Matchers::HaveHtmlLink
- Defined in:
- lib/dommy/rails/rspec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(mail) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(text, href:, count:) ⇒ HaveHtmlLink
constructor
A new instance of HaveHtmlLink.
- #matches?(mail) ⇒ Boolean
Constructor Details
#initialize(text, href:, count:) ⇒ HaveHtmlLink
Returns a new instance of HaveHtmlLink.
699 700 701 702 703 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 699 def initialize(text, href:, count:) @text = text @href = href @count = count end |
Instance Method Details
#description ⇒ Object
717 718 719 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 717 def description "have HTML link" end |
#does_not_match?(mail) ⇒ Boolean
713 714 715 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 713 def does_not_match?(mail) !matches?(mail) end |
#failure_message ⇒ Object
721 722 723 724 725 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 721 def return "expected mail to have an HTML part" unless @document "expected mail HTML to contain link, found #{@matched.size}" end |
#failure_message_when_negated ⇒ Object
727 728 729 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 727 def "expected mail HTML not to contain link" end |
#matches?(mail) ⇒ Boolean
705 706 707 708 709 710 711 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 705 def matches?(mail) @document = Dommy::Rails::MailPart.html_document(mail) return false unless @document @matched = Dommy::Rails::PageInspector.links(@document, text: @text, href: @href) Dommy::Internal::DomMatching.count_matches?(@matched.size, @count) end |