Class: Bogus::Injector

Inherits:
Object
  • Object
show all
Includes:
Dependor::AutoInject
Defined in:
lib/bogus/injector.rb

Instance Method Summary collapse

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_doublesObject



69
70
71
# File 'lib/bogus/injector.rb', line 69

def clear_tracked_doubles
  @double_tracker = nil
end

#configurationObject



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_fakesObject



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_trackerObject



65
66
67
# File 'lib/bogus/injector.rb', line 65

def double_tracker
  @double_tracker ||= inject(TracksExistenceOfTestDoubles)
end

#doubled_interactionsObject



77
78
79
# File 'lib/bogus/injector.rb', line 77

def doubled_interactions
  @doubled_interactions ||= inject(InteractionsRepository)
end

#fake_configurationObject



10
11
12
# File 'lib/bogus/injector.rb', line 10

def fake_configuration
  @fake_configuration ||= inject(FakeConfiguration)
end

#fake_registryObject



18
19
20
# File 'lib/bogus/injector.rb', line 18

def fake_registry
  @fake_registry ||= inject(FakeRegistry)
end

#have_received_matcherObject



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_repositoryObject



61
62
63
# File 'lib/bogus/injector.rb', line 61

def interactions_repository
  raise "Specify either real_interactions or stubbed_interactions"
end

#method_copiersObject



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_classesObject



81
82
83
# File 'lib/bogus/injector.rb', line 81

def overwritten_classes
  @overwritten_classes ||= inject(OverwrittenClasses)
end

#real_interactionsObject



73
74
75
# File 'lib/bogus/injector.rb', line 73

def real_interactions
  @real_interactions ||= inject(InteractionsRepository)
end

#search_modulesObject



14
15
16
# File 'lib/bogus/injector.rb', line 14

def search_modules
  configuration.search_modules
end