Module: Recruit
- Defined in:
- lib/speq/recruit.rb
Overview
Some characters you can recruit for your tests
Defined Under Namespace
Class Method Summary collapse
- .duck(**mapping) ⇒ Object
-
.fake(class_name = 'Fake', super_class: Object, namespace: Object, avoid_collisions: false, &block) ⇒ Object
Will let you claim ‘fake(’Lies’).equal?(Lies)‘.
- .spy(proxy_target = nil, permit_all_methods = false) ⇒ Object
Class Method Details
.duck(**mapping) ⇒ Object
7 8 9 |
# File 'lib/speq/recruit.rb', line 7 def duck(**mapping) Duck.new(**mapping) end |
.fake(class_name = 'Fake', super_class: Object, namespace: Object, avoid_collisions: false, &block) ⇒ Object
Will let you claim ‘fake(’Lies’).equal?(Lies)‘
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/speq/recruit.rb', line 71 def fake( class_name = 'Fake', super_class: Object, namespace: Object, avoid_collisions: false, &block ) if avoid_collisions && namespace.const_defined?(class_name) throw NameError( "constant '#{class_name}' already defined for #{namespace}" ) end namespace.const_set(class_name, Class.new(super_class, &block)) end |
.spy(proxy_target = nil, permit_all_methods = false) ⇒ Object
11 12 13 |
# File 'lib/speq/recruit.rb', line 11 def spy(proxy_target = nil, permit_all_methods = false) Spy.new(proxy_target, permit_all_methods) end |