lib/bogus/injector.rb in bogus-0.0.2 vs lib/bogus/injector.rb in bogus-0.0.3.rc.1

- old
+ new

@@ -2,61 +2,83 @@ class Injector include Dependor::AutoInject look_in_modules Bogus def configuration - @configuration ||= Bogus::Configuration.new + @configuration ||= inject(Configuration) end + def fake_configuration + @fake_configuration ||= inject(FakeConfiguration) + end + def search_modules configuration.search_modules end def rr_proxy Bogus::RRProxy end + def rr_shadow(object) + inject(Bogus::RRShadow, object: object) + end + def fake_registry - @fake_registry ||= inject(Bogus::FakeRegistry) + @fake_registry ||= inject(FakeRegistry) end def creates_fakes - creates_fakes = inject(Bogus::CreatesFakes) - inject(Bogus::RegistersCreatedFakes, creates_fakes: creates_fakes) + creates_fakes = inject(CreatesFakes) + inject(RegistersCreatedFakes, creates_fakes: creates_fakes) end + def create_double(object) + inject(Double, object: object) + end + def create_stub(object) - stub = rr_proxy.stub(object) - inject(Bogus::Double, object: object, double: stub) + create_double(object).stub end def create_mock(object) - mock = rr_proxy.mock(object) - inject(Bogus::Double, object: object, double: mock) + create_double(object).mock end - def invocation_matcher(method = nil) - inject(Bogus::InvocationMatcher, method: method) + def have_received_matcher + inject(HaveReceivedMatcher) end def interactions_repository raise "Specify either real_interactions or stubbed_interactions" end + def double_tracker + @double_tracker ||= inject(TracksExistenceOfTestDoubles) + end + + def clear_tracked_doubles + @double_tracker = nil + end + def real_interactions - @real_interactions ||= inject(Bogus::InteractionsRepository) + @real_interactions ||= inject(InteractionsRepository) end def doubled_interactions - @doubled_interactions ||= inject(Bogus::InteractionsRepository) + @doubled_interactions ||= inject(InteractionsRepository) end + def overwritten_classes + @overwritten_classes ||= inject(OverwrittenClasses) + end + def create_proxy_class(fake_name, klass) - inject(Bogus::ProxyClass, fake_name: fake_name, klass: klass) + inject(ProxyClass, fake_name: fake_name, klass: klass) end def create_recording_proxy(instance, fake_name) - inject(Bogus::RecordingProxy, + inject(RecordingProxy, instance: instance, fake_name: fake_name, interactions_repository: real_interactions) end end