Sha256: dd55a12baa05861107918dd567f0c0606ad29bc62aa093d3184fac1d03ceb1ad

Contents?: true

Size: 761 Bytes

Versions: 6

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module Rubysmith
  module Builders
    module RSpec
      # Builds RSpec spec helper for project skeleton.
      class Helper
        def self.call(...) = new(...).call

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

        def call
          return unless configuration.build_rspec

          builder.call(configuration.with(template_path: "%project_name%/spec/spec_helper.rb.erb"))
                 .render
                 .replace(/\n{3,}/, "\n\n")
                 .replace(/\n\s{2}(?=(require|Simple|using|Pathname|Dir))/, "\n")
        end

        private

        attr_reader :configuration, :builder
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysmith-0.16.1 lib/rubysmith/builders/rspec/helper.rb
rubysmith-0.16.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-0.15.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-0.14.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-0.13.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-0.12.0 lib/rubysmith/builders/rspec/helper.rb