Class: Rubysmith::Builders::RSpec::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysmith/builders/rspec/helper.rb

Overview

Builds RSpec spec helper for project skeleton.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, builder: Builder) ⇒ Helper

Returns a new instance of Helper.



10
11
12
13
# File 'lib/rubysmith/builders/rspec/helper.rb', line 10

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

Class Method Details

.call(configuration, builder: Builder) ⇒ Object



8
# File 'lib/rubysmith/builders/rspec/helper.rb', line 8

def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
# 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