Sha256: 96176bafb83ca7ba3f6643b2e65ef8493b530cbcaf28fc81dc8f5af6769ec5dc

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require "refinements/struct"

module Hanamismith
  module Builders
    module RSpec
      # Builds project skeleton RSpec helper.
      class Helper < Rubysmith::Builders::RSpec::Helper
        using Refinements::Struct

        def initialize(...)
          super
          @instance = builder.call configuration.merge(
            template_path: "%project_name%/spec/spec_helper.rb.erb"
          )
        end

        def call
          return configuration unless configuration.build_rspec

          super
          remove_project_requirement
          disable_simple_cov_eval
          configuration
        end

        private

        attr_reader :instance

        def remove_project_requirement
          instance.replace(/require.+#{configuration.project_name}.+\n/, "")
        end

        def disable_simple_cov_eval
          instance.replace(
            /enable_coverage_for_eval\n/,
            "# TODO: Enable once this issue is fixed: " \
            "https://bugs.ruby-lang.org/issues/19363.\n    " \
            "# enable_coverage_for_eval\n"
          )
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hanamismith-0.34.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.33.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.32.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.31.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.30.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.29.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.28.1 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.28.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.27.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.26.0 lib/hanamismith/builders/rspec/helper.rb
hanamismith-0.25.0 lib/hanamismith/builders/rspec/helper.rb