Sha256: bcbc7e52584ea60d51c18717316f23734925f4db82bfa21ed7982cb3f2f7f364

Contents?: true

Size: 851 Bytes

Versions: 8

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

require "refinements/struct"

module Gemsmith
  module Builders
    module RSpec
      # Builds RSpec spec helper for project skeleton.
      class Helper
        using Refinements::Struct

        def self.call(...) = new(...).call

        def initialize configuration, builder: Rubysmith::Builder
          @configuration = configuration
          @builder = builder
        end

        def call
          return configuration unless configuration.build_rspec && configuration.build_cli

          builder.call(configuration.merge(template_path: "%project_name%/spec/spec_helper.rb.erb"))
                 .touch
                 .replace("%r(^/spec/)", "%r((.+/container\\.rb|^/spec/))")
          configuration
        end

        private

        attr_reader :configuration, :builder
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gemsmith-21.6.0 lib/gemsmith/builders/rspec/helper.rb
gemsmith-21.5.1 lib/gemsmith/builders/rspec/helper.rb
gemsmith-21.5.0 lib/gemsmith/builders/rspec/helper.rb
gemsmith-21.4.0 lib/gemsmith/builders/rspec/helper.rb
gemsmith-21.3.0 lib/gemsmith/builders/rspec/helper.rb
gemsmith-21.2.0 lib/gemsmith/builders/rspec/helper.rb
gemsmith-21.1.0 lib/gemsmith/builders/rspec/helper.rb
gemsmith-21.0.0 lib/gemsmith/builders/rspec/helper.rb