Sha256: c3fd73abf05835245e7691f2ce35035b3093dedb3d92c4fe774dc1e9d50cf0be

Contents?: true

Size: 860 Bytes

Versions: 5

Compression:

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

5 entries across 5 versions & 1 rubygems

Version Path
gemsmith-13.6.0 lib/gemsmith/generators/rspec.rb
gemsmith-13.5.0 lib/gemsmith/generators/rspec.rb
gemsmith-13.4.0 lib/gemsmith/generators/rspec.rb
gemsmith-13.3.0 lib/gemsmith/generators/rspec.rb
gemsmith-13.2.0 lib/gemsmith/generators/rspec.rb