factory_girl 2.0.0.rc4 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,6 +20,7 @@ Install
20
20
  gem install factory_girl
21
21
  ```
22
22
  or add the following line to Gemfile:
23
+
23
24
  ```ruby
24
25
  gem 'factory_girl'
25
26
  ```
@@ -0,0 +1,45 @@
1
+ Feature: Factory girl can find factory definitions correctly
2
+ Scenario: Find definitions with a path
3
+ Given a file named "awesome_factories.rb" with:
4
+ """
5
+ FactoryGirl.define do
6
+ factory :awesome_category, :parent => :category do
7
+ name "awesome!!!"
8
+ end
9
+ end
10
+ """
11
+ When "awesome_factories.rb" is added to Factory Girl's file definitions path
12
+ And I create a "awesome_category" instance from Factory Girl
13
+ Then I should find the following for the last category:
14
+ | name |
15
+ | awesome!!! |
16
+
17
+ Scenario: Find definitions with an absolute path
18
+ Given a file named "awesome_factories.rb" with:
19
+ """
20
+ FactoryGirl.define do
21
+ factory :awesome_category, :parent => :category do
22
+ name "awesome!!!"
23
+ end
24
+ end
25
+ """
26
+ When "awesome_factories.rb" is added to Factory Girl's file definitions path as an absolute path
27
+ And I create a "awesome_category" instance from Factory Girl
28
+ Then I should find the following for the last category:
29
+ | name |
30
+ | awesome!!! |
31
+
32
+ Scenario: Find definitions with a folder
33
+ Given a file named "nested/great_factories.rb" with:
34
+ """
35
+ FactoryGirl.define do
36
+ factory :great_category, :parent => :category do
37
+ name "great!!!"
38
+ end
39
+ end
40
+ """
41
+ When "nested" is added to Factory Girl's file definitions path
42
+ And I create a "great_category" instance from Factory Girl
43
+ Then I should find the following for the last category:
44
+ | name |
45
+ | great!!! |
@@ -0,0 +1,18 @@
1
+ When /^"([^"]*)" is added to Factory Girl's file definitions path$/ do |file_name|
2
+ new_factory_file = File.join(current_dir, file_name.gsub(".rb", ""))
3
+ FactoryGirl.definition_file_paths ||= []
4
+ FactoryGirl.definition_file_paths << new_factory_file
5
+ FactoryGirl.find_definitions
6
+ end
7
+
8
+ When /^"([^"]*)" is added to Factory Girl's file definitions path as an absolute path$/ do |file_name|
9
+ new_factory_file = File.expand_path(File.join(current_dir, file_name.gsub(".rb", "")))
10
+
11
+ FactoryGirl.definition_file_paths ||= []
12
+ FactoryGirl.definition_file_paths << new_factory_file
13
+ FactoryGirl.find_definitions
14
+ end
15
+
16
+ When /^I create a "([^"]*)" instance from Factory Girl$/ do |factory_name|
17
+ FactoryGirl.create(factory_name)
18
+ end
@@ -4,3 +4,5 @@ $: << File.join(PROJECT_ROOT, 'lib')
4
4
 
5
5
  require 'active_record'
6
6
  require 'factory_girl'
7
+
8
+ require 'aruba/cucumber'
Binary file
@@ -11,6 +11,8 @@ module FactoryGirl
11
11
 
12
12
  def self.find_definitions #:nodoc:
13
13
  definition_file_paths.each do |path|
14
+ path = File.expand_path(path)
15
+
14
16
  require("#{path}.rb") if File.exists?("#{path}.rb")
15
17
 
16
18
  if File.directory? path
@@ -1,4 +1,4 @@
1
1
  module FactoryGirl
2
- VERSION = "2.0.0.rc4"
2
+ VERSION = "2.0.1"
3
3
  end
4
4
 
@@ -14,6 +14,10 @@ describe "an instance generated by a factory that inherits from another factory"
14
14
  admin true
15
15
  email "admin@example.com"
16
16
  end
17
+
18
+ factory :guest do
19
+ email { "#{name}-guest@example.com" }
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -31,5 +35,10 @@ describe "an instance generated by a factory that inherits from another factory"
31
35
  its(:name) { should == "John" }
32
36
  its(:email) { should == "admin@example.com" }
33
37
  end
38
+
39
+ describe "the child class with parent attribute" do
40
+ subject { FactoryGirl.create(:guest) }
41
+ its(:email) { should eql "John-guest@example.com" }
42
+ end
34
43
  end
35
44
 
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  RSpec::Matchers.define :require_definitions_from do |file|
12
12
  match do |given|
13
- @has_received = have_received.method_missing(:require, file)
13
+ @has_received = have_received.method_missing(:require, File.expand_path(file))
14
14
  @has_received.matches?(given)
15
15
  end
16
16
 
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 2.0.0.rc4
4
+ hash: 13
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 1
10
+ version: 2.0.1
6
11
  platform: ruby
7
12
  authors:
8
13
  - Joe Ferris
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-07-08 00:00:00 -04:00
18
+ date: 2011-07-22 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,9 @@ dependencies:
21
26
  requirements:
22
27
  - - ">="
23
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
24
32
  version: "0"
25
33
  type: :development
26
34
  version_requirements: *id001
@@ -32,6 +40,9 @@ dependencies:
32
40
  requirements:
33
41
  - - ">="
34
42
  - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
35
46
  version: "0"
36
47
  type: :development
37
48
  version_requirements: *id002
@@ -43,6 +54,9 @@ dependencies:
43
54
  requirements:
44
55
  - - ">="
45
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
46
60
  version: "0"
47
61
  type: :development
48
62
  version_requirements: *id003
@@ -54,6 +68,11 @@ dependencies:
54
68
  requirements:
55
69
  - - ~>
56
70
  - !ruby/object:Gem::Version
71
+ hash: 9
72
+ segments:
73
+ - 2
74
+ - 3
75
+ - 5
57
76
  version: 2.3.5
58
77
  type: :development
59
78
  version_requirements: *id004
@@ -65,6 +84,13 @@ dependencies:
65
84
  requirements:
66
85
  - - ~>
67
86
  - !ruby/object:Gem::Version
87
+ hash: 62196421
88
+ segments:
89
+ - 3
90
+ - 0
91
+ - 0
92
+ - beta
93
+ - 3
68
94
  version: 3.0.0.beta3
69
95
  type: :development
70
96
  version_requirements: *id005
@@ -76,6 +102,9 @@ dependencies:
76
102
  requirements:
77
103
  - - ">="
78
104
  - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
79
108
  version: "0"
80
109
  type: :development
81
110
  version_requirements: *id006
@@ -87,9 +116,26 @@ dependencies:
87
116
  requirements:
88
117
  - - ">="
89
118
  - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
90
122
  version: "0"
91
123
  type: :development
92
124
  version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ name: aruba
127
+ prerelease: false
128
+ requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ type: :development
138
+ version_requirements: *id008
93
139
  description: |-
94
140
  factory_girl provides a framework and DSL for defining and
95
141
  using factories - less error-prone, more explicit, and
@@ -183,7 +229,9 @@ files:
183
229
  - spec/factory_girl_spec.rb
184
230
  - spec/spec_helper.rb
185
231
  - features/factory_girl_steps.feature
232
+ - features/find_definitions.feature
186
233
  - features/step_definitions/database_steps.rb
234
+ - features/step_definitions/factory_girl_steps.rb
187
235
  - features/support/env.rb
188
236
  - features/support/factories.rb
189
237
  - features/support/test.db
@@ -201,13 +249,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
249
  requirements:
202
250
  - - ">="
203
251
  - !ruby/object:Gem::Version
252
+ hash: 3
253
+ segments:
254
+ - 0
204
255
  version: "0"
205
256
  required_rubygems_version: !ruby/object:Gem::Requirement
206
257
  none: false
207
258
  requirements:
208
- - - ">"
259
+ - - ">="
209
260
  - !ruby/object:Gem::Version
210
- version: 1.3.1
261
+ hash: 3
262
+ segments:
263
+ - 0
264
+ version: "0"
211
265
  requirements: []
212
266
 
213
267
  rubyforge_project:
@@ -255,7 +309,9 @@ test_files:
255
309
  - spec/factory_girl/sequence_spec.rb
256
310
  - spec/factory_girl_spec.rb
257
311
  - features/factory_girl_steps.feature
312
+ - features/find_definitions.feature
258
313
  - features/step_definitions/database_steps.rb
314
+ - features/step_definitions/factory_girl_steps.rb
259
315
  - features/support/env.rb
260
316
  - features/support/factories.rb
261
317
  - features/support/test.db