class Rubysmith::Builders::RSpec::Helper

Builds RSpec spec helper for project skeleton.

Public Class Methods

call(...) click to toggle source
# File lib/rubysmith/builders/rspec/helper.rb, line 8
  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
new(configuration, builder: Builder) click to toggle source
# File lib/rubysmith/builders/rspec/helper.rb, line 10
def initialize configuration, builder: Builder
  @configuration = configuration
  @builder = builder
end

Public Instance Methods

call() click to toggle source
# File lib/rubysmith/builders/rspec/helper.rb, line 15
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