Class: StubFactory::InstanceFactory
- Inherits:
-
Object
- Object
- StubFactory::InstanceFactory
- Defined in:
- lib/stub_factory.rb
Overview
InstanceFactory does all the work. You can access it directly but you should probably just include StubFactory and use the factory helper method.
BTW, It’s called InstanceFactory and not just Factory so it can be included when you’re using FactoryGirl
Instance Method Summary collapse
-
#initialize(receiver, klass, options = {}) ⇒ InstanceFactory
constructor
We don’t want to extend all strings in case you’ve got your own underscore method.
- #method_name ⇒ Object
- #result ⇒ Object
- #stub!(stubs = {}) ⇒ Object
- #with(args) ⇒ Object
Constructor Details
#initialize(receiver, klass, options = {}) ⇒ InstanceFactory
We don’t want to extend all strings in case you’ve got your own underscore method.
28 29 30 31 32 |
# File 'lib/stub_factory.rb', line 28 def initialize(receiver, klass, = {}) @receiver = receiver @klass = klass @method_name = [:method_name] end |
Instance Method Details
#method_name ⇒ Object
48 49 50 |
# File 'lib/stub_factory.rb', line 48 def method_name @method_name || klass_name end |
#result ⇒ Object
44 45 46 |
# File 'lib/stub_factory.rb', line 44 def result retrieve_instance || publish_instance end |
#stub!(stubs = {}) ⇒ Object
39 40 41 42 |
# File 'lib/stub_factory.rb', line 39 def stub!(stubs = {}) @stubs = stubs self end |
#with(args) ⇒ Object
34 35 36 37 |
# File 'lib/stub_factory.rb', line 34 def with(args) @args = args self end |