Sha256: 89deee12c02bdce67d31a1f523c6f21ff3181170137b29adb566f61d62806f86

Contents?: true

Size: 860 Bytes

Versions: 12

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 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 rspec_root
        "%gem_name%/spec"
      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

12 entries across 12 versions & 1 rubygems

Version Path
gemsmith-14.2.0 lib/gemsmith/generators/rspec.rb
gemsmith-14.1.3 lib/gemsmith/generators/rspec.rb
gemsmith-14.1.2 lib/gemsmith/generators/rspec.rb
gemsmith-14.1.1 lib/gemsmith/generators/rspec.rb
gemsmith-14.1.0 lib/gemsmith/generators/rspec.rb
gemsmith-14.0.2 lib/gemsmith/generators/rspec.rb
gemsmith-14.0.1 lib/gemsmith/generators/rspec.rb
gemsmith-14.0.0 lib/gemsmith/generators/rspec.rb
gemsmith-13.8.0 lib/gemsmith/generators/rspec.rb
gemsmith-13.7.2 lib/gemsmith/generators/rspec.rb
gemsmith-13.7.1 lib/gemsmith/generators/rspec.rb
gemsmith-13.7.0 lib/gemsmith/generators/rspec.rb