Sha256: 1bf1a4bcb271b570a714f40033dea0db672efaedf630c16fa3e708516f24e2c4

Contents?: true

Size: 862 Bytes

Versions: 3

Compression:

Stored size: 862 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
        template "#{rspec_root}/spec_helper.rb.tt"
        install_rails_helper
        template "#{rspec_root}/support/shared_contexts/temp_dir.rb.tt"
      end

      def install_rails_helper
        return unless configuration.dig(:generate, :engine)

        template "#{rspec_root}/rails_helper.rb.tt"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gemsmith-13.1.0 lib/gemsmith/generators/rspec.rb
gemsmith-13.0.0 lib/gemsmith/generators/rspec.rb
gemsmith-12.4.0 lib/gemsmith/generators/rspec.rb