File: mailer_example_group.rb

package info (click to toggle)
ruby-rspec-rails 8.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,820 kB
  • sloc: ruby: 10,902; sh: 199; makefile: 6
file content (38 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module RSpec
  module Rails
    # @api public
    # Container module for mailer spec functionality. It is only available if
    # ActionMailer has been loaded before it.
    module MailerExampleGroup
      # This blank module is only necessary for YARD processing. It doesn't
      # handle the conditional `defined?` check below very well.
    end
  end
end

if defined?(ActionMailer)
  module RSpec
    module Rails
      # Container module for mailer spec functionality.
      module MailerExampleGroup
        extend ActiveSupport::Concern
        include RSpec::Rails::RailsExampleGroup
        include ActionMailer::TestCase::Behavior

        included do
          include ::Rails.application.routes.url_helpers
          options = ::Rails.configuration.action_mailer.default_url_options || {}
          options.each { |key, value| default_url_options[key] = value }
        end

        # Class-level DSL for mailer specs.
        module ClassMethods
          # Alias for `described_class`.
          def mailer_class
            described_class
          end
        end
      end
    end
  end
end