factory_girl_kibiz0r 2.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Appraisals +12 -0
- data/CONTRIBUTION_GUIDELINES.md +9 -0
- data/Changelog +29 -0
- data/GETTING_STARTED.md +246 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +62 -0
- data/LICENSE +19 -0
- data/README.md +64 -0
- data/Rakefile +54 -0
- data/features/factory_girl_steps.feature +151 -0
- data/features/step_definitions/database_steps.rb +20 -0
- data/features/support/env.rb +6 -0
- data/features/support/factories.rb +84 -0
- data/lib/factory_girl/aliases.rb +21 -0
- data/lib/factory_girl/attribute/association.rb +24 -0
- data/lib/factory_girl/attribute/callback.rb +16 -0
- data/lib/factory_girl/attribute/dynamic.rb +21 -0
- data/lib/factory_girl/attribute/implicit.rb +36 -0
- data/lib/factory_girl/attribute/list.rb +19 -0
- data/lib/factory_girl/attribute/sequence.rb +16 -0
- data/lib/factory_girl/attribute/static.rb +18 -0
- data/lib/factory_girl/attribute.rb +42 -0
- data/lib/factory_girl/definition_proxy.rb +147 -0
- data/lib/factory_girl/deprecated.rb +18 -0
- data/lib/factory_girl/factory.rb +196 -0
- data/lib/factory_girl/find_definitions.rb +23 -0
- data/lib/factory_girl/proxy/attributes_for.rb +21 -0
- data/lib/factory_girl/proxy/build.rb +36 -0
- data/lib/factory_girl/proxy/create.rb +16 -0
- data/lib/factory_girl/proxy/stub.rb +64 -0
- data/lib/factory_girl/proxy.rb +87 -0
- data/lib/factory_girl/rails2.rb +1 -0
- data/lib/factory_girl/registry.rb +45 -0
- data/lib/factory_girl/sequence.rb +31 -0
- data/lib/factory_girl/step_definitions.rb +60 -0
- data/lib/factory_girl/syntax/blueprint.rb +42 -0
- data/lib/factory_girl/syntax/default.rb +33 -0
- data/lib/factory_girl/syntax/generate.rb +73 -0
- data/lib/factory_girl/syntax/make.rb +41 -0
- data/lib/factory_girl/syntax/methods.rb +86 -0
- data/lib/factory_girl/syntax/sham.rb +45 -0
- data/lib/factory_girl/syntax/vintage.rb +152 -0
- data/lib/factory_girl/syntax.rb +12 -0
- data/lib/factory_girl/version.rb +4 -0
- data/lib/factory_girl.rb +54 -0
- data/spec/acceptance/acceptance_helper.rb +11 -0
- data/spec/acceptance/attribute_aliases_spec.rb +26 -0
- data/spec/acceptance/attributes_for_spec.rb +48 -0
- data/spec/acceptance/build_spec.rb +35 -0
- data/spec/acceptance/build_stubbed_spec.rb +79 -0
- data/spec/acceptance/callbacks_spec.rb +53 -0
- data/spec/acceptance/create_spec.rb +67 -0
- data/spec/acceptance/default_strategy_spec.rb +27 -0
- data/spec/acceptance/definition_spec.rb +28 -0
- data/spec/acceptance/parent_spec.rb +39 -0
- data/spec/acceptance/sequence_spec.rb +34 -0
- data/spec/acceptance/syntax/blueprint_spec.rb +32 -0
- data/spec/acceptance/syntax/generate_spec.rb +60 -0
- data/spec/acceptance/syntax/make_spec.rb +35 -0
- data/spec/acceptance/syntax/sham_spec.rb +44 -0
- data/spec/acceptance/syntax/vintage_spec.rb +224 -0
- data/spec/factory_girl/aliases_spec.rb +33 -0
- data/spec/factory_girl/attribute/association_spec.rb +33 -0
- data/spec/factory_girl/attribute/callback_spec.rb +23 -0
- data/spec/factory_girl/attribute/dynamic_spec.rb +60 -0
- data/spec/factory_girl/attribute/implicit_spec.rb +50 -0
- data/spec/factory_girl/attribute/sequence_spec.rb +21 -0
- data/spec/factory_girl/attribute/static_spec.rb +29 -0
- data/spec/factory_girl/attribute_spec.rb +39 -0
- data/spec/factory_girl/definition_proxy_spec.rb +129 -0
- data/spec/factory_girl/deprecated_spec.rb +66 -0
- data/spec/factory_girl/factory_spec.rb +374 -0
- data/spec/factory_girl/find_definitions_spec.rb +100 -0
- data/spec/factory_girl/proxy/attributes_for_spec.rb +52 -0
- data/spec/factory_girl/proxy/build_spec.rb +86 -0
- data/spec/factory_girl/proxy/create_spec.rb +107 -0
- data/spec/factory_girl/proxy/stub_spec.rb +80 -0
- data/spec/factory_girl/proxy_spec.rb +102 -0
- data/spec/factory_girl/registry_spec.rb +83 -0
- data/spec/factory_girl/sequence_spec.rb +96 -0
- data/spec/factory_girl_spec.rb +17 -0
- data/spec/spec_helper.rb +93 -0
- metadata +294 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec/autorun'
|
7
|
+
require 'rr'
|
8
|
+
|
9
|
+
require 'factory_girl'
|
10
|
+
|
11
|
+
module RR
|
12
|
+
module Adapters
|
13
|
+
module Rspec
|
14
|
+
def self.included(mod)
|
15
|
+
RSpec.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.mock_framework = :rr
|
23
|
+
RSpec::Core::ExampleGroup.send(:include, RR::Adapters::Rspec)
|
24
|
+
config.after do
|
25
|
+
FactoryGirl.factories.clear
|
26
|
+
FactoryGirl.sequences.clear
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module DefinesConstants
|
31
|
+
def self.included(example_group)
|
32
|
+
example_group.class_eval do
|
33
|
+
before do
|
34
|
+
@defined_constants = []
|
35
|
+
@created_tables = []
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
@defined_constants.reverse.each do |path|
|
40
|
+
namespace, class_name = *constant_path(path)
|
41
|
+
namespace.send(:remove_const, class_name)
|
42
|
+
end
|
43
|
+
|
44
|
+
@created_tables.each do |table_name|
|
45
|
+
ActiveRecord::Base.
|
46
|
+
connection.
|
47
|
+
execute("DROP TABLE IF EXISTS #{table_name}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def define_class(path, base = Object, &block)
|
52
|
+
namespace, class_name = *constant_path(path)
|
53
|
+
klass = Class.new(base)
|
54
|
+
namespace.const_set(class_name, klass)
|
55
|
+
klass.class_eval(&block) if block_given?
|
56
|
+
@defined_constants << path
|
57
|
+
klass
|
58
|
+
end
|
59
|
+
|
60
|
+
def define_model(name, columns = {}, &block)
|
61
|
+
model = define_class(name, ActiveRecord::Base, &block)
|
62
|
+
create_table(model.table_name) do |table|
|
63
|
+
columns.each do |name, type|
|
64
|
+
table.column name, type
|
65
|
+
end
|
66
|
+
end
|
67
|
+
model
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_table(table_name, &block)
|
71
|
+
connection = ActiveRecord::Base.connection
|
72
|
+
|
73
|
+
begin
|
74
|
+
connection.execute("DROP TABLE IF EXISTS #{table_name}")
|
75
|
+
connection.create_table(table_name, &block)
|
76
|
+
@created_tables << table_name
|
77
|
+
connection
|
78
|
+
rescue Exception => exception
|
79
|
+
connection.execute("DROP TABLE IF EXISTS #{table_name}")
|
80
|
+
raise exception
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def constant_path(constant_name)
|
85
|
+
names = constant_name.split('::')
|
86
|
+
class_name = names.pop
|
87
|
+
namespace = names.inject(Object) { |result, name| result.const_get(name) }
|
88
|
+
[namespace, class_name]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
metadata
ADDED
@@ -0,0 +1,294 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: factory_girl_kibiz0r
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: -1848230038
|
5
|
+
prerelease: true
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- beta2
|
11
|
+
version: 2.0.0.beta2
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- Joe Ferris
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-05-25 00:00:00 -04:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: rcov
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: cucumber
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: activerecord
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 9
|
73
|
+
segments:
|
74
|
+
- 2
|
75
|
+
- 3
|
76
|
+
- 5
|
77
|
+
version: 2.3.5
|
78
|
+
type: :development
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: activerecord
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: -1848230021
|
89
|
+
segments:
|
90
|
+
- 3
|
91
|
+
- 0
|
92
|
+
- 0
|
93
|
+
- beta3
|
94
|
+
version: 3.0.0.beta3
|
95
|
+
type: :development
|
96
|
+
version_requirements: *id005
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rr
|
99
|
+
prerelease: false
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
type: :development
|
110
|
+
version_requirements: *id006
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
prerelease: false
|
114
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
type: :development
|
124
|
+
version_requirements: *id007
|
125
|
+
description: |-
|
126
|
+
factory_girl provides a framework and DSL for defining and
|
127
|
+
using factories - less error-prone, more explicit, and
|
128
|
+
all-around easier to work with than fixtures.
|
129
|
+
email: jferris@thoughtbot.com
|
130
|
+
executables: []
|
131
|
+
|
132
|
+
extensions: []
|
133
|
+
|
134
|
+
extra_rdoc_files: []
|
135
|
+
|
136
|
+
files:
|
137
|
+
- Appraisals
|
138
|
+
- Changelog
|
139
|
+
- CONTRIBUTION_GUIDELINES.md
|
140
|
+
- Gemfile
|
141
|
+
- Gemfile.lock
|
142
|
+
- GETTING_STARTED.md
|
143
|
+
- LICENSE
|
144
|
+
- Rakefile
|
145
|
+
- README.md
|
146
|
+
- lib/factory_girl/aliases.rb
|
147
|
+
- lib/factory_girl/attribute/association.rb
|
148
|
+
- lib/factory_girl/attribute/callback.rb
|
149
|
+
- lib/factory_girl/attribute/dynamic.rb
|
150
|
+
- lib/factory_girl/attribute/implicit.rb
|
151
|
+
- lib/factory_girl/attribute/list.rb
|
152
|
+
- lib/factory_girl/attribute/sequence.rb
|
153
|
+
- lib/factory_girl/attribute/static.rb
|
154
|
+
- lib/factory_girl/attribute.rb
|
155
|
+
- lib/factory_girl/definition_proxy.rb
|
156
|
+
- lib/factory_girl/deprecated.rb
|
157
|
+
- lib/factory_girl/factory.rb
|
158
|
+
- lib/factory_girl/find_definitions.rb
|
159
|
+
- lib/factory_girl/proxy/attributes_for.rb
|
160
|
+
- lib/factory_girl/proxy/build.rb
|
161
|
+
- lib/factory_girl/proxy/create.rb
|
162
|
+
- lib/factory_girl/proxy/stub.rb
|
163
|
+
- lib/factory_girl/proxy.rb
|
164
|
+
- lib/factory_girl/rails2.rb
|
165
|
+
- lib/factory_girl/registry.rb
|
166
|
+
- lib/factory_girl/sequence.rb
|
167
|
+
- lib/factory_girl/step_definitions.rb
|
168
|
+
- lib/factory_girl/syntax/blueprint.rb
|
169
|
+
- lib/factory_girl/syntax/default.rb
|
170
|
+
- lib/factory_girl/syntax/generate.rb
|
171
|
+
- lib/factory_girl/syntax/make.rb
|
172
|
+
- lib/factory_girl/syntax/methods.rb
|
173
|
+
- lib/factory_girl/syntax/sham.rb
|
174
|
+
- lib/factory_girl/syntax/vintage.rb
|
175
|
+
- lib/factory_girl/syntax.rb
|
176
|
+
- lib/factory_girl/version.rb
|
177
|
+
- lib/factory_girl.rb
|
178
|
+
- spec/acceptance/acceptance_helper.rb
|
179
|
+
- spec/acceptance/attribute_aliases_spec.rb
|
180
|
+
- spec/acceptance/attributes_for_spec.rb
|
181
|
+
- spec/acceptance/build_spec.rb
|
182
|
+
- spec/acceptance/build_stubbed_spec.rb
|
183
|
+
- spec/acceptance/callbacks_spec.rb
|
184
|
+
- spec/acceptance/create_spec.rb
|
185
|
+
- spec/acceptance/default_strategy_spec.rb
|
186
|
+
- spec/acceptance/definition_spec.rb
|
187
|
+
- spec/acceptance/parent_spec.rb
|
188
|
+
- spec/acceptance/sequence_spec.rb
|
189
|
+
- spec/acceptance/syntax/blueprint_spec.rb
|
190
|
+
- spec/acceptance/syntax/generate_spec.rb
|
191
|
+
- spec/acceptance/syntax/make_spec.rb
|
192
|
+
- spec/acceptance/syntax/sham_spec.rb
|
193
|
+
- spec/acceptance/syntax/vintage_spec.rb
|
194
|
+
- spec/factory_girl/aliases_spec.rb
|
195
|
+
- spec/factory_girl/attribute/association_spec.rb
|
196
|
+
- spec/factory_girl/attribute/callback_spec.rb
|
197
|
+
- spec/factory_girl/attribute/dynamic_spec.rb
|
198
|
+
- spec/factory_girl/attribute/implicit_spec.rb
|
199
|
+
- spec/factory_girl/attribute/sequence_spec.rb
|
200
|
+
- spec/factory_girl/attribute/static_spec.rb
|
201
|
+
- spec/factory_girl/attribute_spec.rb
|
202
|
+
- spec/factory_girl/definition_proxy_spec.rb
|
203
|
+
- spec/factory_girl/deprecated_spec.rb
|
204
|
+
- spec/factory_girl/factory_spec.rb
|
205
|
+
- spec/factory_girl/find_definitions_spec.rb
|
206
|
+
- spec/factory_girl/proxy/attributes_for_spec.rb
|
207
|
+
- spec/factory_girl/proxy/build_spec.rb
|
208
|
+
- spec/factory_girl/proxy/create_spec.rb
|
209
|
+
- spec/factory_girl/proxy/stub_spec.rb
|
210
|
+
- spec/factory_girl/proxy_spec.rb
|
211
|
+
- spec/factory_girl/registry_spec.rb
|
212
|
+
- spec/factory_girl/sequence_spec.rb
|
213
|
+
- spec/factory_girl_spec.rb
|
214
|
+
- spec/spec_helper.rb
|
215
|
+
- features/factory_girl_steps.feature
|
216
|
+
- features/step_definitions/database_steps.rb
|
217
|
+
- features/support/env.rb
|
218
|
+
- features/support/factories.rb
|
219
|
+
has_rdoc: true
|
220
|
+
homepage: http://thoughtbot.com/projects/factory_girl
|
221
|
+
licenses: []
|
222
|
+
|
223
|
+
post_install_message:
|
224
|
+
rdoc_options: []
|
225
|
+
|
226
|
+
require_paths:
|
227
|
+
- lib
|
228
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
229
|
+
none: false
|
230
|
+
requirements:
|
231
|
+
- - ">="
|
232
|
+
- !ruby/object:Gem::Version
|
233
|
+
hash: 3
|
234
|
+
segments:
|
235
|
+
- 0
|
236
|
+
version: "0"
|
237
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
|
+
none: false
|
239
|
+
requirements:
|
240
|
+
- - ">"
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
hash: 25
|
243
|
+
segments:
|
244
|
+
- 1
|
245
|
+
- 3
|
246
|
+
- 1
|
247
|
+
version: 1.3.1
|
248
|
+
requirements: []
|
249
|
+
|
250
|
+
rubyforge_project:
|
251
|
+
rubygems_version: 1.3.7
|
252
|
+
signing_key:
|
253
|
+
specification_version: 3
|
254
|
+
summary: factory_girl provides a framework and DSL for defining and using model instance factories. (Includes ignorable attributes.)
|
255
|
+
test_files:
|
256
|
+
- spec/acceptance/attribute_aliases_spec.rb
|
257
|
+
- spec/acceptance/attributes_for_spec.rb
|
258
|
+
- spec/acceptance/build_spec.rb
|
259
|
+
- spec/acceptance/build_stubbed_spec.rb
|
260
|
+
- spec/acceptance/callbacks_spec.rb
|
261
|
+
- spec/acceptance/create_spec.rb
|
262
|
+
- spec/acceptance/default_strategy_spec.rb
|
263
|
+
- spec/acceptance/definition_spec.rb
|
264
|
+
- spec/acceptance/parent_spec.rb
|
265
|
+
- spec/acceptance/sequence_spec.rb
|
266
|
+
- spec/acceptance/syntax/blueprint_spec.rb
|
267
|
+
- spec/acceptance/syntax/generate_spec.rb
|
268
|
+
- spec/acceptance/syntax/make_spec.rb
|
269
|
+
- spec/acceptance/syntax/sham_spec.rb
|
270
|
+
- spec/acceptance/syntax/vintage_spec.rb
|
271
|
+
- spec/factory_girl/aliases_spec.rb
|
272
|
+
- spec/factory_girl/attribute/association_spec.rb
|
273
|
+
- spec/factory_girl/attribute/callback_spec.rb
|
274
|
+
- spec/factory_girl/attribute/dynamic_spec.rb
|
275
|
+
- spec/factory_girl/attribute/implicit_spec.rb
|
276
|
+
- spec/factory_girl/attribute/sequence_spec.rb
|
277
|
+
- spec/factory_girl/attribute/static_spec.rb
|
278
|
+
- spec/factory_girl/attribute_spec.rb
|
279
|
+
- spec/factory_girl/definition_proxy_spec.rb
|
280
|
+
- spec/factory_girl/deprecated_spec.rb
|
281
|
+
- spec/factory_girl/factory_spec.rb
|
282
|
+
- spec/factory_girl/find_definitions_spec.rb
|
283
|
+
- spec/factory_girl/proxy/attributes_for_spec.rb
|
284
|
+
- spec/factory_girl/proxy/build_spec.rb
|
285
|
+
- spec/factory_girl/proxy/create_spec.rb
|
286
|
+
- spec/factory_girl/proxy/stub_spec.rb
|
287
|
+
- spec/factory_girl/proxy_spec.rb
|
288
|
+
- spec/factory_girl/registry_spec.rb
|
289
|
+
- spec/factory_girl/sequence_spec.rb
|
290
|
+
- spec/factory_girl_spec.rb
|
291
|
+
- features/factory_girl_steps.feature
|
292
|
+
- features/step_definitions/database_steps.rb
|
293
|
+
- features/support/env.rb
|
294
|
+
- features/support/factories.rb
|