Module: HasMockObjects::ClassMethods
- Includes:
- LocalInstanceMethods
- Defined in:
- lib/has_mock_objects.rb
Constant Summary
Constants included from LocalInstanceMethods
LocalInstanceMethods::FAKERSHORTCUTS
Instance Method Summary collapse
Methods included from LocalInstanceMethods
#mock_attributes, #mock_objects
Instance Method Details
#has_many_mocks(obj, number, *attrs) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/has_mock_objects.rb', line 51 def has_many_mocks(obj, number, *attrs) attributes = attrs. send :define_method, obj do mock_objects[obj] ||= ( mocks = [] rand(number).times do mocks << mock_attributes(attributes) end mocks ) @mock_objects[obj] end end |
#has_one_mock(obj, *attrs) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/has_mock_objects.rb', line 65 def has_one_mock(obj, *attrs) attributes = attrs. send :define_method, obj do mock_objects[obj] ||= mock_attributes(attributes) end end |