Class: Bogus::Injector
- Inherits:
-
Object
- Object
- Bogus::Injector
- Includes:
- Dependor::AutoInject
- Defined in:
- lib/bogus/injector.rb
Instance Method Summary collapse
- #active_record_accessors(klass) ⇒ Object
- #adds_contract_verification(syntax) ⇒ Object
- #class_methods(klass) ⇒ Object
- #clear_tracked_doubles ⇒ Object
- #configuration ⇒ Object
- #create_double(object) ⇒ Object
- #create_mock(object) ⇒ Object
- #create_proxy_class(fake_name, klass) ⇒ Object
- #create_recording_proxy(instance, fake_name) ⇒ Object
- #create_stub(object) ⇒ Object
- #creates_fakes ⇒ Object
- #double_tracker ⇒ Object
- #doubled_interactions ⇒ Object
- #fake_configuration ⇒ Object
- #fake_registry ⇒ Object
- #have_received_matcher ⇒ Object
- #instance_methods(klass) ⇒ Object
- #interactions_repository ⇒ Object
- #method_copiers ⇒ Object
- #overwritten_classes ⇒ Object
- #real_interactions ⇒ Object
- #search_modules ⇒ Object
Instance Method Details
#active_record_accessors(klass) ⇒ Object
47 48 49 |
# File 'lib/bogus/injector.rb', line 47 def active_record_accessors(klass) inject(ActiveRecordAccessors, klass: klass) end |
#adds_contract_verification(syntax) ⇒ Object
85 86 87 |
# File 'lib/bogus/injector.rb', line 85 def adds_contract_verification(syntax) inject(AddsContractVerification, syntax: syntax) end |
#class_methods(klass) ⇒ Object
43 44 45 |
# File 'lib/bogus/injector.rb', line 43 def class_methods(klass) inject(ClassMethods, klass: klass) end |
#clear_tracked_doubles ⇒ Object
69 70 71 |
# File 'lib/bogus/injector.rb', line 69 def clear_tracked_doubles @double_tracker = nil end |
#configuration ⇒ Object
6 7 8 |
# File 'lib/bogus/injector.rb', line 6 def configuration @configuration ||= inject(Configuration) end |
#create_double(object) ⇒ Object
27 28 29 |
# File 'lib/bogus/injector.rb', line 27 def create_double(object) inject(Double, object: object) end |
#create_mock(object) ⇒ Object
35 36 37 |
# File 'lib/bogus/injector.rb', line 35 def create_mock(object) create_double(object).mock end |
#create_proxy_class(fake_name, klass) ⇒ Object
89 90 91 |
# File 'lib/bogus/injector.rb', line 89 def create_proxy_class(fake_name, klass) inject(ProxyClass, fake_name: fake_name, klass: klass) end |
#create_recording_proxy(instance, fake_name) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/bogus/injector.rb', line 93 def create_recording_proxy(instance, fake_name) inject(RecordingProxy, instance: instance, fake_name: fake_name, interactions_repository: real_interactions) end |
#create_stub(object) ⇒ Object
31 32 33 |
# File 'lib/bogus/injector.rb', line 31 def create_stub(object) create_double(object).stub end |
#creates_fakes ⇒ Object
22 23 24 25 |
# File 'lib/bogus/injector.rb', line 22 def creates_fakes creates_fakes = inject(CreatesFakes) inject(RegistersCreatedFakes, creates_fakes: creates_fakes) end |
#double_tracker ⇒ Object
65 66 67 |
# File 'lib/bogus/injector.rb', line 65 def double_tracker @double_tracker ||= inject(TracksExistenceOfTestDoubles) end |
#doubled_interactions ⇒ Object
77 78 79 |
# File 'lib/bogus/injector.rb', line 77 def doubled_interactions @doubled_interactions ||= inject(InteractionsRepository) end |
#fake_configuration ⇒ Object
10 11 12 |
# File 'lib/bogus/injector.rb', line 10 def fake_configuration @fake_configuration ||= inject(FakeConfiguration) end |
#fake_registry ⇒ Object
18 19 20 |
# File 'lib/bogus/injector.rb', line 18 def fake_registry @fake_registry ||= inject(FakeRegistry) end |
#have_received_matcher ⇒ Object
57 58 59 |
# File 'lib/bogus/injector.rb', line 57 def have_received_matcher inject(HaveReceivedMatcher) end |
#instance_methods(klass) ⇒ Object
39 40 41 |
# File 'lib/bogus/injector.rb', line 39 def instance_methods(klass) inject(InstanceMethods, klass: klass) end |
#interactions_repository ⇒ Object
61 62 63 |
# File 'lib/bogus/injector.rb', line 61 def interactions_repository raise "Specify either real_interactions or stubbed_interactions" end |
#method_copiers ⇒ Object
51 52 53 54 55 |
# File 'lib/bogus/injector.rb', line 51 def method_copiers copiers = [method(:class_methods), method(:instance_methods)] copiers << method(:active_record_accessors) if configuration.fake_ar_attributes copiers end |
#overwritten_classes ⇒ Object
81 82 83 |
# File 'lib/bogus/injector.rb', line 81 def overwritten_classes @overwritten_classes ||= inject(OverwrittenClasses) end |
#real_interactions ⇒ Object
73 74 75 |
# File 'lib/bogus/injector.rb', line 73 def real_interactions @real_interactions ||= inject(InteractionsRepository) end |
#search_modules ⇒ Object
14 15 16 |
# File 'lib/bogus/injector.rb', line 14 def search_modules configuration.search_modules end |