Sha256: 1fcd03139b23cc78d78b68f2029e06716a707661f1c55982dbb89bb4e8abecd8

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 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
        cli.template("#{rspec_root}/rails_helper.rb.tt", configuration) if configuration.dig(:generate, :rails)
        cli.template "#{rspec_root}/support/shared_contexts/temp_dir.rb.tt", configuration
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemsmith-8.2.0 lib/gemsmith/generators/rspec.rb