object-daddy 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -137,6 +137,10 @@ A simple default block is provided for any generator with a :start value.
137
137
  generator_for :name, :start => 'Joe' # equivalent to the above
138
138
  end
139
139
 
140
+ You can reset a class' generators to their initial value by calling:
141
+
142
+ User.reset_generators!
143
+
140
144
  The _:method_ form takes a symbol naming a class method in the model class to be
141
145
  called to generate a new value for the attribute in question. If the method
142
146
  takes a single argument, it will act much like the block method of invocation,
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.1.0
data/lib/object_daddy.rb CHANGED
@@ -89,6 +89,15 @@ module ObjectDaddy
89
89
  end
90
90
  end
91
91
 
92
+ def reset_generators!
93
+ generators.each do |handle, generator|
94
+ if generator[:generator][:initial]
95
+ generator[:generator][:start] = generator[:generator][:initial]
96
+ end
97
+ generator[:generator].delete :prev
98
+ end
99
+ end
100
+
92
101
  def generates_subclass(subclass_name)
93
102
  @concrete_subclass_name = subclass_name.to_s
94
103
  end
@@ -159,6 +168,7 @@ module ObjectDaddy
159
168
  def process_generated_value(args, handle, generator, block)
160
169
  if generator[:start]
161
170
  value = generator[:start]
171
+ generator[:initial] = value
162
172
  generator.delete(:start)
163
173
  else
164
174
  if block.arity == 0
data/object-daddy.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "object-daddy"
8
- s.version = "1.0.2"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rick Bradley", "Yossef Mendelssohn", "Jeremy Holland"]
12
- s.date = "2012-05-11"
12
+ s.date = "2012-11-26"
13
13
  s.description = "Object Daddy is a library (as well as a Ruby on Rails plugin) designed to assist in automating testing of large collections of objects, especially webs of ActiveRecord models. It is a descendent of the \"Object Mother\" pattern for creating objects for testing, and is related to the concept of an \"object exemplar\" or stereotype."
14
14
  s.email = ["blogicx@rickbradley.com", "ymendel@pobox.com", "jeremy@jeremypholland.com"]
15
15
  s.extra_rdoc_files = [
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
38
38
  s.homepage = "http://github.com/awebneck/object_daddy"
39
39
  s.licenses = ["MIT"]
40
40
  s.require_paths = ["lib"]
41
- s.rubygems_version = "1.8.15"
41
+ s.rubygems_version = "1.8.24"
42
42
  s.summary = "Kill Fixtures"
43
43
 
44
44
  if s.respond_to? :specification_version then
@@ -264,6 +264,33 @@ describe ObjectDaddy, 'when registering exemplars' do
264
264
  end
265
265
  end
266
266
 
267
+ describe ObjectDaddy, "when resetting a class instance" do
268
+ before(:each) do
269
+ @class = Class.new(OpenStruct)
270
+ @class.send(:include, ObjectDaddy)
271
+ @file_path = [File.join(File.dirname(__FILE__), 'tmp')]
272
+ @file_name = File.join(@file_path, 'widget_exemplar.rb')
273
+ @class.stubs(:exemplar_path).returns(@file_path)
274
+ @class.stubs(:name).returns('Widget')
275
+ end
276
+
277
+ it "should return the initial value once more after calling if the start value is specified" do
278
+ @class.generator_for :foo, :start => 'frobnitz' do |prev| prev + 'a'; end
279
+ @class.spawn
280
+ @class.spawn
281
+ @class.reset_generators!
282
+ @class.spawn.foo.should == 'frobnitz'
283
+ end
284
+
285
+ it "should pass nil for the previous item after calling" do
286
+ @class.generator_for :foo do |prev| prev ? prev.succ : 'hats'; end
287
+ @class.spawn
288
+ @class.spawn
289
+ @class.reset_generators!
290
+ @class.spawn.foo.should == 'hats'
291
+ end
292
+ end
293
+
267
294
  describe ObjectDaddy, "when spawning a class instance" do
268
295
  before(:each) do
269
296
  @class = Class.new(OpenStruct)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object-daddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-05-11 00:00:00.000000000 Z
14
+ date: 2012-11-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &9311700 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,15 @@ dependencies:
23
23
  version: 2.8.0
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *9311700
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: 2.8.0
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: rdoc
29
- requirement: &9308560 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
30
35
  none: false
31
36
  requirements:
32
37
  - - ~>
@@ -34,10 +39,15 @@ dependencies:
34
39
  version: '3.12'
35
40
  type: :development
36
41
  prerelease: false
37
- version_requirements: *9308560
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: bundler
40
- requirement: &9307460 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ~>
@@ -45,10 +55,15 @@ dependencies:
45
55
  version: 1.0.0
46
56
  type: :development
47
57
  prerelease: false
48
- version_requirements: *9307460
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: 1.0.0
49
64
  - !ruby/object:Gem::Dependency
50
65
  name: jeweler
51
- requirement: &9305600 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ~>
@@ -56,10 +71,15 @@ dependencies:
56
71
  version: 1.8.3
57
72
  type: :development
58
73
  prerelease: false
59
- version_requirements: *9305600
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 1.8.3
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: rails
62
- requirement: &9318600 !ruby/object:Gem::Requirement
82
+ requirement: !ruby/object:Gem::Requirement
63
83
  none: false
64
84
  requirements:
65
85
  - - ! '>='
@@ -67,10 +87,15 @@ dependencies:
67
87
  version: 3.0.0
68
88
  type: :development
69
89
  prerelease: false
70
- version_requirements: *9318600
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: 3.0.0
71
96
  - !ruby/object:Gem::Dependency
72
97
  name: generator_spec
73
- requirement: &9317120 !ruby/object:Gem::Requirement
98
+ requirement: !ruby/object:Gem::Requirement
74
99
  none: false
75
100
  requirements:
76
101
  - - ! '>='
@@ -78,10 +103,15 @@ dependencies:
78
103
  version: '0'
79
104
  type: :development
80
105
  prerelease: false
81
- version_requirements: *9317120
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
82
112
  - !ruby/object:Gem::Dependency
83
113
  name: sqlite3
84
- requirement: &9315060 !ruby/object:Gem::Requirement
114
+ requirement: !ruby/object:Gem::Requirement
85
115
  none: false
86
116
  requirements:
87
117
  - - ! '>='
@@ -89,10 +119,15 @@ dependencies:
89
119
  version: '0'
90
120
  type: :development
91
121
  prerelease: false
92
- version_requirements: *9315060
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
93
128
  - !ruby/object:Gem::Dependency
94
129
  name: rspec-rails
95
- requirement: &9313360 !ruby/object:Gem::Requirement
130
+ requirement: !ruby/object:Gem::Requirement
96
131
  none: false
97
132
  requirements:
98
133
  - - ! '>='
@@ -100,10 +135,15 @@ dependencies:
100
135
  version: '0'
101
136
  type: :development
102
137
  prerelease: false
103
- version_requirements: *9313360
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
104
144
  - !ruby/object:Gem::Dependency
105
145
  name: pry
106
- requirement: &9328200 !ruby/object:Gem::Requirement
146
+ requirement: !ruby/object:Gem::Requirement
107
147
  none: false
108
148
  requirements:
109
149
  - - ! '>='
@@ -111,10 +151,15 @@ dependencies:
111
151
  version: '0'
112
152
  type: :development
113
153
  prerelease: false
114
- version_requirements: *9328200
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
115
160
  - !ruby/object:Gem::Dependency
116
161
  name: mocha
117
- requirement: &9326560 !ruby/object:Gem::Requirement
162
+ requirement: !ruby/object:Gem::Requirement
118
163
  none: false
119
164
  requirements:
120
165
  - - ! '>='
@@ -122,7 +167,12 @@ dependencies:
122
167
  version: '0'
123
168
  type: :development
124
169
  prerelease: false
125
- version_requirements: *9326560
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
126
176
  description: Object Daddy is a library (as well as a Ruby on Rails plugin) designed
127
177
  to assist in automating testing of large collections of objects, especially webs
128
178
  of ActiveRecord models. It is a descendent of the "Object Mother" pattern for creating
@@ -169,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
219
  version: '0'
170
220
  segments:
171
221
  - 0
172
- hash: -2776455863744275124
222
+ hash: 1074228485709639567
173
223
  required_rubygems_version: !ruby/object:Gem::Requirement
174
224
  none: false
175
225
  requirements:
@@ -178,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
228
  version: '0'
179
229
  requirements: []
180
230
  rubyforge_project:
181
- rubygems_version: 1.8.15
231
+ rubygems_version: 1.8.24
182
232
  signing_key:
183
233
  specification_version: 3
184
234
  summary: Kill Fixtures