Welcome to mirror list, hosted at ThFree Co, Russian Federation.

have_plain_text_content.rb « matchers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 94f65ce377195019c8af60116c39d36a767e7aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

# can be replaced with https://github.com/email-spec/email-spec/pull/196 in the future
RSpec::Matchers.define :have_plain_text_content do |expected_text|
  match do |actual_email|
    plain_text_body(actual_email).include? expected_text
  end

  failure_message do |actual_email|
    "Expected email\n#{plain_text_body(actual_email).indent(2)}\nto contain\n#{expected_text.indent(2)}"
  end

  def plain_text_body(email)
    email.text_part.body.to_s
  end
end