Sha256: 7b20a2a638230440be91d0228905cfd478e4e52f44a99137a7f0f8496d94b574

Contents?: true

Size: 837 Bytes

Versions: 7

Compression:

Stored size: 837 Bytes

Contents

# frozen_string_literal: true

require "dry/core/container/stub"

module Dry
  module System
    class Container
      # @api private
      module Stubs
        # This overrides default finalize! just to disable automatic freezing
        # of the container
        #
        # @api private
        def finalize!(**, &block)
          super(freeze: false, &block)
        end
      end

      # Enables stubbing container's components
      #
      # @example
      #   require 'dry/system/stubs'
      #
      #   MyContainer.enable_stubs!
      #   MyContainer.finalize!
      #
      #   MyContainer.stub('some.component', some_stub_object)
      #
      # @return Container
      #
      # @api public
      def self.enable_stubs!
        super
        extend ::Dry::System::Container::Stubs
        self
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dry-system-1.1.1 lib/dry/system/stubs.rb
dry-system-1.1.0 lib/dry/system/stubs.rb
dry-system-1.1.0.beta2 lib/dry/system/stubs.rb
dry-system-1.1.0.beta1 lib/dry/system/stubs.rb
dry-system-1.0.1 lib/dry/system/stubs.rb
dry-system-1.0.0 lib/dry/system/stubs.rb
dry-system-1.0.0.rc1 lib/dry/system/stubs.rb