Sha256: 7cc12f3340d91bd9a2c36ee0ee3d1a4ba5d55fb7250ece136db1409576de1c89

Contents?: true

Size: 876 Bytes

Versions: 8

Compression:

Stored size: 876 Bytes

Contents

require 'sanitize_email/test_helpers'

module SanitizeEmail
  module RspecMatchers
    include SanitizeEmail::TestHelpers
    [:from, :to, :cc, :bcc, :subject, :reply_to].each do |attribute|
      RSpec::Matchers.define "have_#{attribute}" do |matcher|
        match do |actual|
          email_matching(matcher, attribute, actual)
        end
      end
    end

    [:from, :to, :cc, :bcc, :subject, :reply_to].each do |attribute|
      RSpec::Matchers.define "be_#{attribute}" do |matcher|
        match do |actual|
          string_matching(matcher, attribute, actual)
        end
      end
    end

    RSpec::Matchers.define "have_to_username" do |matcher|
      def get_username(email_message)
        email_message.header.fields[3].value
      end
      match do |actual|
        string_matching(matcher, :to_username, get_username(actual))
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sanitize_email-1.0.10 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.9 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.8 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.7 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.6 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.5 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.4 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.3 lib/sanitize_email/rspec_matchers.rb