Sha256: 3e0720177d67af7771c6e0b33bae5d35c092d1e21d707e4d124d9e0551efb6e5

Contents?: true

Size: 813 Bytes

Versions: 8

Compression:

Stored size: 813 Bytes

Contents

require 'generators/rspec'
require "rspec/rails/feature_check"

module Rspec
  module Generators
    # @private
    class MailerGenerator < Base
      argument :actions, type: :array, default: [], banner: "method method"

      def generate_mailer_spec
        template "mailer_spec.rb", target_path('mailers', class_path, "#{file_name}_spec.rb")
      end

      def generate_fixtures_files
        actions.each do |action|
          @action, @path = action, File.join(file_path, action)
          template "fixture", target_path("fixtures", @path)
        end
      end

      def generate_preview_files
        return unless RSpec::Rails::FeatureCheck.has_action_mailer_preview?

        template "preview.rb", target_path("mailers/previews", class_path, "#{file_name}_preview.rb")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/rspec-rails-6.0.4/lib/generators/rspec/mailer/mailer_generator.rb
rspec-rails-6.1.1 lib/generators/rspec/mailer/mailer_generator.rb
rspec-rails-6.1.0 lib/generators/rspec/mailer/mailer_generator.rb
rspec-rails-6.0.4 lib/generators/rspec/mailer/mailer_generator.rb
rspec-rails-6.0.3 lib/generators/rspec/mailer/mailer_generator.rb
rspec-rails-6.0.2 lib/generators/rspec/mailer/mailer_generator.rb
rspec-rails-6.0.1 lib/generators/rspec/mailer/mailer_generator.rb
rspec-rails-6.0.0 lib/generators/rspec/mailer/mailer_generator.rb