Report abuse


			
## written by David Lowenfels @ Internaut Design
## may be used/modified as long as credit is given

    def assert_emails_sent args = {}, &block
      opts = args.dup
      array_headers = [ :to, :from ]
      # if was pass a string as :to, or :from, then it implies an array with one member
      array_headers.each do |sym|
        opts[sym] = opts[sym].email if opts[sym].respond_to? :email  # convert to email if sent object with email attribute
        opts[sym] = []< 1), &block
      return ActionMailer::Base.deliveries.first
    end

    def assert_email_not_sent
      ActionMailer::Base.deliveries.clear
      yield
      assert ActionMailer::Base.deliveries.empty?, "Email was unexpectedly sent"
    end