Class: Dommy::Rails::RSpec::Matchers::HaveHtmlText
- Inherits:
-
Object
- Object
- Dommy::Rails::RSpec::Matchers::HaveHtmlText
- 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) ⇒ HaveHtmlText
constructor
A new instance of HaveHtmlText.
- #matches?(mail) ⇒ Boolean
Constructor Details
#initialize(text) ⇒ HaveHtmlText
Returns a new instance of HaveHtmlText.
733 734 735 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 733 def initialize(text) @text = text end |
Instance Method Details
#description ⇒ Object
749 750 751 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 749 def description "have HTML text #{@text.inspect}" end |
#does_not_match?(mail) ⇒ Boolean
745 746 747 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 745 def does_not_match?(mail) !matches?(mail) end |
#failure_message ⇒ Object
753 754 755 756 757 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 753 def return "expected mail to have an HTML part" unless @document "expected mail HTML to include #{@text.inspect}, got #{@actual.inspect}" end |
#failure_message_when_negated ⇒ Object
759 760 761 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 759 def "expected mail HTML not to include #{@text.inspect}" end |
#matches?(mail) ⇒ Boolean
737 738 739 740 741 742 743 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 737 def matches?(mail) @document = Dommy::Rails::MailPart.html_document(mail) return false unless @document @actual = Dommy::Internal::DomMatching.text_of(@document) Dommy::Internal::DomMatching.text_matches?(@actual, @text) end |