Sha256: eb843fe6b1519adec59c12463314c5e1bfe93406dc3e18f02ad5777e859567a6

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

# Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
# Released under the MIT license
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

2 entries across 2 versions & 1 rubygems

Version Path
sanitize_email-1.1.0 lib/sanitize_email/rspec_matchers.rb
sanitize_email-1.0.11 lib/sanitize_email/rspec_matchers.rb