Sha256: f110f39fc08bd8e55180dac6c5eec2438530eab91e8b40d802cd25379766ebc8

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

module Rubysmith
  module Builders
    module RSpec
      # Builds RSpec shared context for temporary directories.
      class Context
        def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call

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

        def call
          return unless configuration.build_rspec

          template = "%project_name%/spec/support/shared_contexts/temp_dir.rb.erb"
          configuration.with(template_path: template)
                       .then { |updated_configuration| builder.call updated_configuration }
                       .render
                       .replace(/\n\s+\n\s+/, "\n  ")
        end

        private

        attr_reader :configuration, :builder
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysmith-0.11.0 lib/rubysmith/builders/rspec/context.rb
rubysmith-0.10.0 lib/rubysmith/builders/rspec/context.rb