Sha256: fca54a1813c90d4077614cb61357cf96333c0393b8ccfa7c0180bb28a730a791

Contents?: true

Size: 766 Bytes

Versions: 6

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

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

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

        def call
          return unless realm.build_rspec

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

        private

        attr_reader :realm, :builder
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysmith-0.9.1 lib/rubysmith/builders/rspec/context.rb
rubysmith-0.9.0 lib/rubysmith/builders/rspec/context.rb
rubysmith-0.8.0 lib/rubysmith/builders/rspec/context.rb
rubysmith-0.7.0 lib/rubysmith/builders/rspec/context.rb
rubysmith-0.6.1 lib/rubysmith/builders/rspec/context.rb
rubysmith-0.6.0 lib/rubysmith/builders/rspec/context.rb