factory_boy 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/lib/plant.rb +4 -3
- data/test/test_plant.rb +7 -0
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -9,6 +9,11 @@ tested, report it in integration tests is a better idea.
|
|
9
9
|
See some examples below.
|
10
10
|
You can see also unit tests / code for deeper comprehension.
|
11
11
|
|
12
|
+
== Install
|
13
|
+
|
14
|
+
gem install factory_boy
|
15
|
+
|
16
|
+
|
12
17
|
== Basic Usage
|
13
18
|
|
14
19
|
Define your Plants (=~ Factories if factory_girl) in test/plants.rb
|
data/lib/plant.rb
CHANGED
@@ -50,10 +50,11 @@ module Plant
|
|
50
50
|
|
51
51
|
def self.pool symbol
|
52
52
|
instance = plants[symbol] || plants[symbol.to_s.camelize.constantize]
|
53
|
-
|
53
|
+
object = instance.dup
|
54
|
+
yield object if block_given?
|
54
55
|
@@pool[instance.class] ||= []
|
55
|
-
@@pool[instance.class] <<
|
56
|
-
|
56
|
+
@@pool[instance.class] << object
|
57
|
+
object
|
57
58
|
end
|
58
59
|
|
59
60
|
def self.destroy
|
data/test/test_plant.rb
CHANGED
@@ -101,6 +101,13 @@ class PlantTest < Test::Unit::TestCase
|
|
101
101
|
assert_equal "incognito2@kantena.com", Plant.next(:email)
|
102
102
|
end
|
103
103
|
|
104
|
+
def test_creation_of_two_plants_of_same_class_should_keep_each_object_safe
|
105
|
+
user_1 = Plant(:user, :name => "Elise")
|
106
|
+
user_2 = Plant(:user, :name => "Vincent")
|
107
|
+
|
108
|
+
assert_equal "Elise", user_1.name
|
109
|
+
end
|
110
|
+
|
104
111
|
private
|
105
112
|
|
106
113
|
def assert_find_is_unstubbed_for_each_class
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_boy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philippe Cantin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-06 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|