Sha256: a88bdf1d3ab3999d61d68acd659b68b867b0501fbce96c581376f1e398282791

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require_relative "base"

module Suspenders
  class TestingGenerator < Generators::Base
    def add_testing_gems
      gem "rspec-rails", "~> 5.1", group: %i[development test]
      gem "shoulda-matchers", group: :test

      Bundler.with_unbundled_env { run "bundle install" }
    end

    def generate_rspec
      generate "rspec:install"
    end

    def configure_rspec
      remove_file "spec/rails_helper.rb"
      remove_file "spec/spec_helper.rb"
      copy_file "rails_helper.rb", "spec/rails_helper.rb"
      copy_file "spec_helper.rb", "spec/spec_helper.rb"
    end

    def provide_shoulda_matchers_config
      copy_file(
        "shoulda_matchers_config_rspec.rb",
        "spec/support/shoulda_matchers.rb"
      )
    end

    def configure_system_tests
      empty_directory_with_keep_file "spec/system"
      empty_directory_with_keep_file "spec/support/system"
    end

    def configure_i18n_for_test_environment
      copy_file "i18n.rb", "spec/support/i18n.rb"
    end

    def configure_action_mailer_in_specs
      copy_file "action_mailer.rb", "spec/support/action_mailer.rb"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
suspenders-20230113.0 lib/suspenders/generators/testing_generator.rb
suspenders-1.56.1 lib/suspenders/generators/testing_generator.rb