freegenie-factory_girl 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,7 @@ class Factory
13
13
  # existing file will be loaded.
14
14
  attr_accessor :definition_file_paths
15
15
  attr_accessor :live_registry
16
+ attr_accessor :use_find_or_create
16
17
  end
17
18
 
18
19
  self.factories = {}
@@ -257,7 +258,11 @@ class Factory
257
258
  # A saved instance of the class this factory generates, with generated
258
259
  # attributes assigned.
259
260
  def self.create (name, overrides = {})
260
- factory_by_name(name).run(Proxy::Create, overrides)
261
+ just_created = factory_by_name(name).run(Proxy::Create, overrides)
262
+ if !just_created.nil?
263
+ live_registry << [name, just_created.class.name, just_created.id]
264
+ end
265
+ just_created
261
266
  end
262
267
 
263
268
  def self.find_or_create (name, overrides = {})
@@ -271,7 +276,9 @@ class Factory
271
276
  end
272
277
  if just_created.nil?
273
278
  just_created = factory_by_name(name).run(Proxy::FindOrCreate, overrides)
274
- live_registry << [name, just_created.class.name, just_created.id]
279
+ if !just_created.nil?
280
+ live_registry << [name, just_created.class.name, just_created.id]
281
+ end
275
282
  end
276
283
  just_created
277
284
  end
@@ -50,6 +50,11 @@ class Factory
50
50
  nil
51
51
  end
52
52
 
53
+ def link(name, overrides = {})
54
+ nil
55
+ end
56
+
57
+
53
58
  def method_missing(method, *args, &block)
54
59
  get(method)
55
60
  end
@@ -13,7 +13,7 @@ class Factory
13
13
  @instance.send(:"#{attribute}=", value)
14
14
  end
15
15
 
16
- def associate(name, factory, attributes)
16
+ def associate(name, factory, attributes)
17
17
  set(name, Factory.create(factory, attributes))
18
18
  end
19
19
 
@@ -16,6 +16,13 @@ class FactoryGirlTest < Test::Unit::TestCase
16
16
 
17
17
  end
18
18
 
19
+ def test_should_link_instead_of_associate
20
+
21
+ john = Factory.create(:john)
22
+ post = Factory.create(:johns_post)
23
+ # post = Factory.create(:johns_post)
24
+ end
25
+
19
26
  def setup
20
27
  teardown
21
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freegenie-factory_girl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Ferris