Sha256: 9f342154720246c69acdf8a7ac0f4c1f23c0f4e1e8526177a704628136c4e197

Contents?: true

Size: 833 Bytes

Versions: 6

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module Rubysmith
  module Builders
    module RSpec
      # Builds RSpec shared context for temporary directories.
      class Context
        def self.call(...) = new(...).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

6 entries across 6 versions & 1 rubygems

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