Sha256: c05b26a46a4214584fd250e735b2525fc81aa3537b03a141dfc4a0e55b5f61ca

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 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

4 entries across 4 versions & 1 rubygems

Version Path
gemsmith-12.3.0 lib/gemsmith/generators/rspec.rb
gemsmith-12.2.0 lib/gemsmith/generators/rspec.rb
gemsmith-12.1.0 lib/gemsmith/generators/rspec.rb
gemsmith-12.0.0 lib/gemsmith/generators/rspec.rb