Class: Dommy::Rails::RSpec::Matchers::HavePlainText

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/rails/rspec/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ HavePlainText

Returns a new instance of HavePlainText.



765
766
767
# File 'lib/dommy/rails/rspec/matchers.rb', line 765

def initialize(text)
  @text = text
end

Instance Method Details

#descriptionObject



778
779
780
# File 'lib/dommy/rails/rspec/matchers.rb', line 778

def description
  "have plain text #{@text.inspect}"
end

#does_not_match?(mail) ⇒ Boolean

Returns:

  • (Boolean)


774
775
776
# File 'lib/dommy/rails/rspec/matchers.rb', line 774

def does_not_match?(mail)
  !matches?(mail)
end

#failure_messageObject



782
783
784
# File 'lib/dommy/rails/rspec/matchers.rb', line 782

def failure_message
  "expected mail plain text to include #{@text.inspect}, got #{@actual.inspect}"
end

#failure_message_when_negatedObject



786
787
788
# File 'lib/dommy/rails/rspec/matchers.rb', line 786

def failure_message_when_negated
  "expected mail plain text not to include #{@text.inspect}"
end

#matches?(mail) ⇒ Boolean

Returns:

  • (Boolean)


769
770
771
772
# File 'lib/dommy/rails/rspec/matchers.rb', line 769

def matches?(mail)
  @actual = Dommy::Rails::MailPart.plain_body(mail).to_s
  Dommy::Internal::DomMatching.text_matches?(@actual, @text)
end