module Corindon::DependencyInjection::Testing::MockUtils
Defines the `mock_definition` on Container
allowing to mock services returned by the container for a given Definition
Public Instance Methods
dup()
click to toggle source
Calls superclass method
# File lib/corindon/dependency_injection/testing/mock_utils.rb, line 28 def dup new_instance = super mocks.each do |definition, value| new_instance.mock_definition(definition, value) end new_instance end
mock_definition(definition, value)
click to toggle source
Allow to provide a specific value that the definition will resolve to @param [Definition] definition @param [Object] value
# File lib/corindon/dependency_injection/testing/mock_utils.rb, line 12 def mock_definition(definition, value) singleton_class.prepend MockUtils unless is_a?(MockUtils) add_definition(definition) if !has?(definition) id = to_id(definition) mocks[definition] = services[id] = value end
mocks()
click to toggle source
# File lib/corindon/dependency_injection/testing/mock_utils.rb, line 24 def mocks @mocks ||= {} end