class RSpec::Rails::Railtie

Railtie to hook into Rails.

def config_default_preview_path(options)

def config_default_preview_path(options)
  return unless options.preview_path.blank?
  options.preview_path = "#{::Rails.root}/spec/mailers/previews"
end

def config_preview_path?(options)

def config_preview_path?(options)
  # We cannot use `respond_to?(:show_previews)` here as it will always
  # return `true`.
  if ::Rails::VERSION::STRING < '4.2'
    ::Rails.env.development?
  elsif options.show_previews.nil?
    options.show_previews = ::Rails.env.development?
  else
    options.show_previews
  end
end

def setup_preview_path(app)

def setup_preview_path(app)
  return unless supports_action_mailer_previews?(app.config)
  options = app.config.action_mailer
  config_default_preview_path(options) if config_preview_path?(options)
end

def supports_action_mailer_previews?(config)

def supports_action_mailer_previews?(config)
  # These checks avoid loading `ActionMailer`. Using `defined?` has the
  # side-effect of the class getting loaded if it is available. This is
  # problematic because loading `ActionMailer::Base` will cause it to
  # read the config settings; this is the only time the config is read.
  # If the config is loaded now, any settings declared in a config block
  # in an initializer will be ignored.
  #
  # If the action mailer railtie has not been loaded then `config` will
  # not respond to the method. However, we cannot use
  # `config.action_mailer.respond_to?(:preview_path)` here as it will
  # always return `true`.
  config.respond_to?(:action_mailer) && ::Rails::VERSION::STRING > '4.1'
end