Sha256: 238e222965ab9f1891c98e2ca27f8a4a0431870e94c10630ceb9ae1b42bbc72f

Contents?: true

Size: 852 Bytes

Versions: 17

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

module Gemsmith
  module Generators
    # Generates RSpec support.
    class Rspec < Base
      def run
        return unless configuration.dig(:generate, :rspec)

        uncomment_lines
        install_templates
      end

      private

      def rspec_root
        "%gem_name%/spec"
      end

      def uncomment_lines
        cli.uncomment_lines "#{gem_name}/Rakefile", /require.+rspec.+/
        cli.uncomment_lines "#{gem_name}/Rakefile", /RSpec.+/
      end

      def install_templates
        cli.template "#{rspec_root}/spec_helper.rb.tt", configuration

        if configuration.dig(:generate, :rails)
          cli.template("#{rspec_root}/rails_helper.rb.tt", configuration)
        end

        cli.template "#{rspec_root}/support/shared_contexts/temp_dir.rb.tt", configuration
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gemsmith-11.1.0 lib/gemsmith/generators/rspec.rb
gemsmith-11.0.1 lib/gemsmith/generators/rspec.rb
gemsmith-11.0.0 lib/gemsmith/generators/rspec.rb
gemsmith-10.4.2 lib/gemsmith/generators/rspec.rb
gemsmith-10.4.1 lib/gemsmith/generators/rspec.rb
gemsmith-10.4.0 lib/gemsmith/generators/rspec.rb
gemsmith-10.3.0 lib/gemsmith/generators/rspec.rb
gemsmith-10.2.0 lib/gemsmith/generators/rspec.rb
gemsmith-10.1.0 lib/gemsmith/generators/rspec.rb
gemsmith-10.0.0 lib/gemsmith/generators/rspec.rb
gemsmith-9.6.0 lib/gemsmith/generators/rspec.rb
gemsmith-9.5.0 lib/gemsmith/generators/rspec.rb
gemsmith-9.4.0 lib/gemsmith/generators/rspec.rb
gemsmith-9.3.0 lib/gemsmith/generators/rspec.rb
gemsmith-9.2.0 lib/gemsmith/generators/rspec.rb
gemsmith-9.1.0 lib/gemsmith/generators/rspec.rb
gemsmith-9.0.0 lib/gemsmith/generators/rspec.rb