factory_girl_rails 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/Appraisals +6 -7
- data/CONTRIBUTING.md +4 -1
- data/Gemfile +8 -8
- data/Gemfile.lock +40 -8
- data/factory_girl_rails.gemspec +1 -3
- data/features/fixture_replacement_config.feature +32 -0
- data/features/generators.feature +29 -3
- data/features/load_definitions.feature +5 -4
- data/features/step_definitions/rails_steps.rb +0 -13
- data/gemfiles/rails3.2.gemfile +8 -3
- data/gemfiles/rails4.1.gemfile +9 -4
- data/gemfiles/rails4.2.gemfile +21 -0
- data/lib/generators/factory_girl.rb +1 -1
- data/lib/generators/factory_girl/model/model_generator.rb +19 -5
- metadata +6 -14
- data/gemfiles/rails4.0.gemfile +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 006b146afdfb102242f6429da252a598d4308d43
|
4
|
+
data.tar.gz: 55f470fca71a220ec5a19bbd9bfbcf3929edd8e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f65bf4191e3ec624d81f34490fd08cf1e54c9b1126e0602168ae5d3e957302464f69448bc9a7c3e3ff92b356b9aa5e025215fe8b1677ebc50b207e1aaebcf9c
|
7
|
+
data.tar.gz: cf56ee37840366d2303ca2d9ce0bed1948577828bfa86dd8cf249f64bcaeedda1f66819ba29e157a4add6189ef087314ae9a4b05b1eeb5ccf560322efc497e74
|
data/.travis.yml
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem update --system
|
2
4
|
cache: bundler
|
3
5
|
rvm:
|
4
|
-
- 1.
|
5
|
-
- 2.
|
6
|
-
- 2.1.2
|
6
|
+
- 2.1.5
|
7
|
+
- 2.2.1
|
7
8
|
- jruby-19mode
|
8
9
|
jdk:
|
9
10
|
- openjdk6
|
@@ -12,9 +13,7 @@ branches:
|
|
12
13
|
- master
|
13
14
|
install:
|
14
15
|
- "travis_retry bundle install"
|
15
|
-
- "bundle exec appraisal generate"
|
16
|
-
- "travis_retry bundle exec appraisal install"
|
17
16
|
gemfile:
|
18
17
|
- gemfiles/rails3.2.gemfile
|
19
|
-
- gemfiles/rails4.0.gemfile
|
20
18
|
- gemfiles/rails4.1.gemfile
|
19
|
+
- gemfiles/rails4.2.gemfile
|
data/Appraisals
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
# These are the versions of Rails we want to test against.
|
2
2
|
appraise 'rails3.2' do
|
3
|
-
gem 'rails', '~> 3.2.
|
3
|
+
gem 'rails', '~> 3.2.21'
|
4
4
|
gem 'sass-rails'
|
5
5
|
end
|
6
6
|
|
7
|
-
appraise 'rails4.
|
8
|
-
gem 'rails', '~> 4.
|
7
|
+
appraise 'rails4.1' do
|
8
|
+
gem 'rails', '~> 4.1.9'
|
9
9
|
gem 'sass-rails'
|
10
|
+
gem 'spring'
|
10
11
|
end
|
11
12
|
|
12
|
-
appraise 'rails4.
|
13
|
-
gem 'rails', '~> 4.
|
14
|
-
gem 'sass-rails', '~> 4.0.3'
|
15
|
-
gem 'spring'
|
13
|
+
appraise 'rails4.2' do
|
14
|
+
gem 'rails', '~> 4.2.0'
|
16
15
|
end
|
data/CONTRIBUTING.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Contributing
|
2
2
|
|
3
|
-
We love pull requests.
|
3
|
+
We love pull requests from everyone. By participating in this project, you
|
4
|
+
agree to abide by the thoughtbot [code of conduct].
|
5
|
+
|
6
|
+
[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
|
4
7
|
|
5
8
|
Fork, then clone the repo:
|
6
9
|
|
data/Gemfile
CHANGED
@@ -5,16 +5,16 @@ gemspec
|
|
5
5
|
gem 'appraisal'
|
6
6
|
gem 'aruba'
|
7
7
|
gem 'coffee-rails'
|
8
|
-
gem 'cucumber'
|
8
|
+
gem 'cucumber', '1.3.19'
|
9
9
|
gem 'jquery-rails'
|
10
10
|
gem 'rake'
|
11
11
|
gem 'rspec-rails'
|
12
12
|
gem 'uglifier'
|
13
|
+
gem 'test-unit'
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
15
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
|
16
|
+
gem 'jdbc-sqlite3', platforms: :jruby
|
17
|
+
gem 'therubyrhino', platforms: :jruby
|
18
|
+
gem 'jruby-openssl', platforms: :jruby
|
19
|
+
|
20
|
+
gem 'sqlite3', platforms: :ruby
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
factory_girl_rails (4.
|
4
|
+
factory_girl_rails (4.6.0)
|
5
5
|
factory_girl (~> 4.5.0)
|
6
6
|
railties (>= 3.0.0)
|
7
7
|
|
@@ -20,16 +20,26 @@ GEM
|
|
20
20
|
activemodel (4.1.1)
|
21
21
|
activesupport (= 4.1.1)
|
22
22
|
builder (~> 3.1)
|
23
|
+
activerecord (4.1.1)
|
24
|
+
activemodel (= 4.1.1)
|
25
|
+
activesupport (= 4.1.1)
|
26
|
+
arel (~> 5.0.0)
|
27
|
+
activerecord-jdbc-adapter (1.3.15)
|
28
|
+
activerecord (>= 2.2)
|
29
|
+
activerecord-jdbcsqlite3-adapter (1.3.15)
|
30
|
+
activerecord-jdbc-adapter (~> 1.3.15)
|
31
|
+
jdbc-sqlite3 (>= 3.7.2, < 3.9)
|
23
32
|
activesupport (4.1.1)
|
24
33
|
i18n (~> 0.6, >= 0.6.9)
|
25
34
|
json (~> 1.7, >= 1.7.7)
|
26
35
|
minitest (~> 5.1)
|
27
36
|
thread_safe (~> 0.1)
|
28
37
|
tzinfo (~> 1.1)
|
29
|
-
appraisal (1.0.
|
38
|
+
appraisal (1.0.3)
|
30
39
|
bundler
|
31
40
|
rake
|
32
41
|
thor (>= 0.14.0)
|
42
|
+
arel (5.0.1.20140414130214)
|
33
43
|
aruba (0.5.4)
|
34
44
|
childprocess (>= 0.3.6)
|
35
45
|
cucumber (>= 1.1.1)
|
@@ -44,28 +54,35 @@ GEM
|
|
44
54
|
coffee-script-source
|
45
55
|
execjs
|
46
56
|
coffee-script-source (1.7.0)
|
47
|
-
cucumber (1.3.
|
57
|
+
cucumber (1.3.19)
|
48
58
|
builder (>= 2.1.2)
|
49
59
|
diff-lcs (>= 1.1.3)
|
50
60
|
gherkin (~> 2.12)
|
51
61
|
multi_json (>= 1.7.5, < 2.0)
|
52
|
-
multi_test (>= 0.1.
|
62
|
+
multi_test (>= 0.1.2)
|
53
63
|
diff-lcs (1.2.5)
|
54
64
|
erubis (2.7.0)
|
55
65
|
execjs (2.0.2)
|
56
66
|
factory_girl (4.5.0)
|
57
67
|
activesupport (>= 3.0.0)
|
58
68
|
ffi (1.9.3)
|
69
|
+
ffi (1.9.3-java)
|
59
70
|
gherkin (2.12.2)
|
60
71
|
multi_json (~> 1.3)
|
72
|
+
gherkin (2.12.2-java)
|
73
|
+
multi_json (~> 1.3)
|
61
74
|
i18n (0.6.9)
|
75
|
+
jdbc-sqlite3 (3.8.7)
|
62
76
|
jquery-rails (3.1.0)
|
63
77
|
railties (>= 3.0, < 5.0)
|
64
78
|
thor (>= 0.14, < 2.0)
|
79
|
+
jruby-openssl (0.9.6-java)
|
65
80
|
json (1.8.1)
|
81
|
+
json (1.8.1-java)
|
66
82
|
minitest (5.3.4)
|
67
|
-
multi_json (1.
|
68
|
-
multi_test (0.1.
|
83
|
+
multi_json (1.11.0)
|
84
|
+
multi_test (0.1.2)
|
85
|
+
power_assert (0.2.3)
|
69
86
|
rack (1.5.2)
|
70
87
|
rack-test (0.6.2)
|
71
88
|
rack (>= 1.0)
|
@@ -74,7 +91,7 @@ GEM
|
|
74
91
|
activesupport (= 4.1.1)
|
75
92
|
rake (>= 0.8.7)
|
76
93
|
thor (>= 0.18.1, < 2.0)
|
77
|
-
rake (10.
|
94
|
+
rake (10.4.2)
|
78
95
|
rspec-core (2.14.8)
|
79
96
|
rspec-expectations (2.14.5)
|
80
97
|
diff-lcs (>= 1.1.3, < 2.0)
|
@@ -88,8 +105,14 @@ GEM
|
|
88
105
|
rspec-expectations (~> 2.14.0)
|
89
106
|
rspec-mocks (~> 2.14.0)
|
90
107
|
sqlite3 (1.3.9)
|
108
|
+
test-unit (3.0.9)
|
109
|
+
power_assert
|
110
|
+
therubyrhino (2.0.4)
|
111
|
+
therubyrhino_jar (>= 1.7.3)
|
112
|
+
therubyrhino_jar (1.7.4)
|
91
113
|
thor (0.19.1)
|
92
114
|
thread_safe (0.3.3)
|
115
|
+
thread_safe (0.3.3-java)
|
93
116
|
tzinfo (1.2.0)
|
94
117
|
thread_safe (~> 0.1)
|
95
118
|
uglifier (2.5.0)
|
@@ -97,16 +120,25 @@ GEM
|
|
97
120
|
json (>= 1.8.0)
|
98
121
|
|
99
122
|
PLATFORMS
|
123
|
+
java
|
100
124
|
ruby
|
101
125
|
|
102
126
|
DEPENDENCIES
|
127
|
+
activerecord-jdbcsqlite3-adapter
|
103
128
|
appraisal
|
104
129
|
aruba
|
105
130
|
coffee-rails
|
106
|
-
cucumber
|
131
|
+
cucumber (= 1.3.19)
|
107
132
|
factory_girl_rails!
|
133
|
+
jdbc-sqlite3
|
108
134
|
jquery-rails
|
135
|
+
jruby-openssl
|
109
136
|
rake
|
110
137
|
rspec-rails
|
111
138
|
sqlite3
|
139
|
+
test-unit
|
140
|
+
therubyrhino
|
112
141
|
uglifier
|
142
|
+
|
143
|
+
BUNDLED WITH
|
144
|
+
1.10.6
|
data/factory_girl_rails.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{factory_girl_rails}
|
3
|
-
s.version = '4.
|
3
|
+
s.version = '4.6.0'
|
4
4
|
s.authors = ["Joe Ferris"]
|
5
5
|
s.email = %q{jferris@thoughtbot.com}
|
6
6
|
s.homepage = "http://github.com/thoughtbot/factory_girl_rails"
|
@@ -11,8 +11,6 @@ Gem::Specification.new do |s|
|
|
11
11
|
loading)}
|
12
12
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
|
-
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
15
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
14
|
s.require_paths = ["lib"]
|
17
15
|
s.license = "MIT"
|
18
16
|
|
@@ -32,6 +32,23 @@ Feature:
|
|
32
32
|
And the following files should not exist:
|
33
33
|
| spec/fixtures/users.yml |
|
34
34
|
|
35
|
+
Scenario: Using Factory Girl and Factory Girl Rails with RSpec and suffix configuration should generate a factory file with suffix
|
36
|
+
When I add "rspec-rails" as a dependency
|
37
|
+
And I configure the factories as:
|
38
|
+
"""
|
39
|
+
config.generators do |g|
|
40
|
+
g.test_framework :rspec, fixture: true
|
41
|
+
g.fixture_replacement :factory_girl, suffix: 'factory'
|
42
|
+
end
|
43
|
+
"""
|
44
|
+
And I run `bundle install` with a clean environment
|
45
|
+
Then the output should contain "rspec-rails"
|
46
|
+
And I run `bundle exec rails generate model User name:string` with a clean environment
|
47
|
+
Then the following files should exist:
|
48
|
+
| spec/factories/users_factory.rb |
|
49
|
+
And the following files should not exist:
|
50
|
+
| spec/fixtures/users.yml |
|
51
|
+
|
35
52
|
Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using RSpec
|
36
53
|
When I add "rspec-rails" as a dependency
|
37
54
|
And I configure the factories directory as "custom/dir"
|
@@ -98,3 +115,18 @@ Feature:
|
|
98
115
|
| spec/factories/users_suffix.rb |
|
99
116
|
Then the following files should not exist:
|
100
117
|
| spec/factories/users.rb |
|
118
|
+
|
119
|
+
Scenario: Use a filename_proc with the Factory Girl generator
|
120
|
+
When I add "rspec-rails" as a dependency
|
121
|
+
When I configure the factories as:
|
122
|
+
"""
|
123
|
+
config.generators do |g|
|
124
|
+
g.factory_girl filename_proc: Proc.new { |tb| "prefix_#{tb.singularize}_suffix" }
|
125
|
+
end
|
126
|
+
"""
|
127
|
+
And I run `bundle install` with a clean environment
|
128
|
+
And I run `bundle exec rails generate model User name:string` with a clean environment
|
129
|
+
Then the following files should exist:
|
130
|
+
| spec/factories/prefix_user_suffix.rb |
|
131
|
+
Then the following files should not exist:
|
132
|
+
| spec/factories/users.rb |
|
data/features/generators.feature
CHANGED
@@ -10,12 +10,38 @@ Feature:
|
|
10
10
|
|
11
11
|
Scenario: The factory_girl_rails generators create a factory file for each model if there is not a factories.rb file
|
12
12
|
When I run `bundle install` with a clean environment
|
13
|
-
And I run `bundle exec rails generate model User name:string` with a clean environment
|
13
|
+
And I run `bundle exec rails generate model User name:string age:integer` with a clean environment
|
14
14
|
And I run `bundle exec rails generate model Namespaced::User name:string` with a clean environment
|
15
15
|
Then the output should contain "test/factories/users.rb"
|
16
16
|
And the output should contain "test/factories/namespaced_users.rb"
|
17
|
-
And the file "test/factories/users.rb" should contain
|
18
|
-
|
17
|
+
And the file "test/factories/users.rb" should contain exactly:
|
18
|
+
"""
|
19
|
+
FactoryGirl.define do
|
20
|
+
factory :user do
|
21
|
+
name "MyString"
|
22
|
+
age 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
"""
|
27
|
+
And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, class: 'Namespaced::User' do"
|
28
|
+
|
29
|
+
Scenario: The factory_girl_rails generators add a factory in the correct spot
|
30
|
+
When I run `bundle install` with a clean environment
|
31
|
+
And I write to "test/factories.rb" with:
|
32
|
+
"""
|
33
|
+
FactoryGirl.define do
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
And I run `bundle exec rails generate model User name:string` with a clean environment
|
37
|
+
Then the file "test/factories.rb" should contain exactly:
|
38
|
+
"""
|
39
|
+
FactoryGirl.define do
|
40
|
+
factory :user do
|
41
|
+
name "MyString"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
"""
|
19
45
|
|
20
46
|
Scenario: The factory_girl_rails generators does not create a factory file for each model if there is a factories.rb file in the test directory
|
21
47
|
When I run `bundle install` with a clean environment
|
@@ -4,6 +4,7 @@ Feature: automatically load step definitions
|
|
4
4
|
When I successfully run `bundle exec rails new testapp`
|
5
5
|
And I cd to "testapp"
|
6
6
|
And I add "factory_girl_rails" from this project as a dependency
|
7
|
+
And I add "test-unit" as a dependency
|
7
8
|
And I run `bundle install` with a clean environment
|
8
9
|
And I write to "db/migrate/1_create_users.rb" with:
|
9
10
|
"""
|
@@ -15,7 +16,7 @@ Feature: automatically load step definitions
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
"""
|
18
|
-
When I run `bundle exec rake db:migrate
|
19
|
+
When I run `bundle exec rake db:migrate` with a clean environment
|
19
20
|
And I write to "app/models/user.rb" with:
|
20
21
|
"""
|
21
22
|
class User < ActiveRecord::Base
|
@@ -42,7 +43,7 @@ Feature: automatically load step definitions
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
"""
|
45
|
-
When I run `bundle exec rake test
|
46
|
+
When I run `bundle exec rake test` with a clean environment
|
46
47
|
Then the output should contain "1 assertions, 0 failures, 0 errors"
|
47
48
|
|
48
49
|
Scenario: use factories advertised by railties/engines/3rd-party gems
|
@@ -64,7 +65,7 @@ Feature: automatically load step definitions
|
|
64
65
|
When I write to "lib/some_railtie/factories.rb" with:
|
65
66
|
"""
|
66
67
|
FactoryGirl.define do
|
67
|
-
factory :factory_from_some_railtie, :
|
68
|
+
factory :factory_from_some_railtie, class: 'User' do
|
68
69
|
name 'Artem'
|
69
70
|
end
|
70
71
|
end
|
@@ -80,5 +81,5 @@ Feature: automatically load step definitions
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
"""
|
83
|
-
When I run `bundle exec rake test
|
84
|
+
When I run `bundle exec rake test` with a clean environment
|
84
85
|
Then the output should contain "1 assertions, 0 failures, 0 errors"
|
@@ -6,19 +6,6 @@ When /^I add "([^"]+)" as a dependency$/ do |gem_name|
|
|
6
6
|
append_to_file('Gemfile', %{gem "#{gem_name}"\n})
|
7
7
|
end
|
8
8
|
|
9
|
-
When /^I set the FactoryGirl :suffix option to "([^"]+)"$/ do |suffix|
|
10
|
-
append_to_file('config/application.rb', <<-RUBY)
|
11
|
-
module Testapp
|
12
|
-
class Application < Rails::Application
|
13
|
-
config.generators do |g|
|
14
|
-
g.fixture_replacement :factory_girl, :suffix => '#{suffix}'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
RUBY
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
9
|
When /^I print out "([^"]*)"$/ do |path|
|
23
10
|
in_current_dir do
|
24
11
|
File.open(path, 'r') do |f|
|
data/gemfiles/rails3.2.gemfile
CHANGED
@@ -5,13 +5,18 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "aruba"
|
7
7
|
gem "coffee-rails"
|
8
|
-
gem "cucumber"
|
8
|
+
gem "cucumber", "1.3.19"
|
9
9
|
gem "jquery-rails"
|
10
10
|
gem "rake"
|
11
11
|
gem "rspec-rails"
|
12
12
|
gem "uglifier"
|
13
|
-
gem "
|
14
|
-
gem "
|
13
|
+
gem "test-unit"
|
14
|
+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
15
|
+
gem "jdbc-sqlite3", :platforms => :jruby
|
16
|
+
gem "therubyrhino", :platforms => :jruby
|
17
|
+
gem "jruby-openssl", :platforms => :jruby
|
18
|
+
gem "sqlite3", :platforms => :ruby
|
19
|
+
gem "rails", "~> 3.2.21"
|
15
20
|
gem "sass-rails"
|
16
21
|
|
17
22
|
gemspec :path => "../"
|
data/gemfiles/rails4.1.gemfile
CHANGED
@@ -5,14 +5,19 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "aruba"
|
7
7
|
gem "coffee-rails"
|
8
|
-
gem "cucumber"
|
8
|
+
gem "cucumber", "1.3.19"
|
9
9
|
gem "jquery-rails"
|
10
10
|
gem "rake"
|
11
11
|
gem "rspec-rails"
|
12
12
|
gem "uglifier"
|
13
|
-
gem "
|
14
|
-
gem "
|
15
|
-
gem "
|
13
|
+
gem "test-unit"
|
14
|
+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
15
|
+
gem "jdbc-sqlite3", :platforms => :jruby
|
16
|
+
gem "therubyrhino", :platforms => :jruby
|
17
|
+
gem "jruby-openssl", :platforms => :jruby
|
18
|
+
gem "sqlite3", :platforms => :ruby
|
19
|
+
gem "rails", "~> 4.1.9"
|
20
|
+
gem "sass-rails"
|
16
21
|
gem "spring"
|
17
22
|
|
18
23
|
gemspec :path => "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "aruba"
|
7
|
+
gem "coffee-rails"
|
8
|
+
gem "cucumber", "1.3.19"
|
9
|
+
gem "jquery-rails"
|
10
|
+
gem "rake"
|
11
|
+
gem "rspec-rails"
|
12
|
+
gem "uglifier"
|
13
|
+
gem "test-unit"
|
14
|
+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
15
|
+
gem "jdbc-sqlite3", :platforms => :jruby
|
16
|
+
gem "therubyrhino", :platforms => :jruby
|
17
|
+
gem "jruby-openssl", :platforms => :jruby
|
18
|
+
gem "sqlite3", :platforms => :ruby
|
19
|
+
gem "rails", "~> 4.2.0"
|
20
|
+
|
21
|
+
gemspec :path => "../"
|
@@ -18,6 +18,13 @@ module FactoryGirl
|
|
18
18
|
desc: "The directory or file root where factories belong"
|
19
19
|
)
|
20
20
|
|
21
|
+
class_option(
|
22
|
+
:suffix,
|
23
|
+
type: :string,
|
24
|
+
default: nil,
|
25
|
+
desc: "Suffix to add factory file"
|
26
|
+
)
|
27
|
+
|
21
28
|
def create_fixture_file
|
22
29
|
if File.exist?(factories_file)
|
23
30
|
insert_factory_into_existing_file
|
@@ -36,12 +43,11 @@ module FactoryGirl
|
|
36
43
|
insert_into_file(
|
37
44
|
factories_file,
|
38
45
|
factory_definition,
|
39
|
-
after: "FactoryGirl.define do"
|
46
|
+
after: "FactoryGirl.define do\n"
|
40
47
|
)
|
41
48
|
end
|
42
49
|
|
43
50
|
def create_factory_file
|
44
|
-
filename = [table_name, filename_suffix].compact.join('_')
|
45
51
|
file = File.join(options[:dir], "#{filename}.rb")
|
46
52
|
create_file(file, single_file_factory_definition)
|
47
53
|
end
|
@@ -49,7 +55,7 @@ module FactoryGirl
|
|
49
55
|
def factory_definition
|
50
56
|
<<-RUBY
|
51
57
|
factory :#{singular_table_name}#{explicit_class_option} do
|
52
|
-
|
58
|
+
#{factory_attributes.gsub(/^/, " ")}
|
53
59
|
end
|
54
60
|
RUBY
|
55
61
|
end
|
@@ -57,7 +63,7 @@ RUBY
|
|
57
63
|
def single_file_factory_definition
|
58
64
|
<<-RUBY
|
59
65
|
FactoryGirl.define do
|
60
|
-
#{factory_definition}
|
66
|
+
#{factory_definition.chomp}
|
61
67
|
end
|
62
68
|
RUBY
|
63
69
|
end
|
@@ -68,8 +74,16 @@ RUBY
|
|
68
74
|
end.join("\n")
|
69
75
|
end
|
70
76
|
|
77
|
+
def filename
|
78
|
+
if factory_girl_options[:filename_proc].present?
|
79
|
+
factory_girl_options[:filename_proc].call(table_name)
|
80
|
+
else
|
81
|
+
[table_name, filename_suffix].compact.join('_')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
71
85
|
def filename_suffix
|
72
|
-
factory_girl_options[:suffix]
|
86
|
+
factory_girl_options[:suffix] || options[:suffix]
|
73
87
|
end
|
74
88
|
|
75
89
|
def factory_girl_options
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Ferris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -43,8 +43,7 @@ description: |-
|
|
43
43
|
factory_girl and rails 3 (currently just automatic factory definition
|
44
44
|
loading)
|
45
45
|
email: jferris@thoughtbot.com
|
46
|
-
executables:
|
47
|
-
- setup
|
46
|
+
executables: []
|
48
47
|
extensions: []
|
49
48
|
extra_rdoc_files: []
|
50
49
|
files:
|
@@ -67,8 +66,8 @@ files:
|
|
67
66
|
- features/step_definitions/rails_steps.rb
|
68
67
|
- features/support/env.rb
|
69
68
|
- gemfiles/rails3.2.gemfile
|
70
|
-
- gemfiles/rails4.0.gemfile
|
71
69
|
- gemfiles/rails4.1.gemfile
|
70
|
+
- gemfiles/rails4.2.gemfile
|
72
71
|
- lib/factory_girl_rails.rb
|
73
72
|
- lib/factory_girl_rails/generator.rb
|
74
73
|
- lib/factory_girl_rails/generators/non_rspec_generator.rb
|
@@ -97,15 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
96
|
version: '0'
|
98
97
|
requirements: []
|
99
98
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.4.5.1
|
101
100
|
signing_key:
|
102
101
|
specification_version: 4
|
103
102
|
summary: factory_girl_rails provides integration between factory_girl and rails 3
|
104
|
-
test_files:
|
105
|
-
- features/fixture_replacement_config.feature
|
106
|
-
- features/generators.feature
|
107
|
-
- features/load_definitions.feature
|
108
|
-
- features/step_definitions/appraisal.rb
|
109
|
-
- features/step_definitions/rails_steps.rb
|
110
|
-
- features/support/env.rb
|
111
|
-
has_rdoc:
|
103
|
+
test_files: []
|
data/gemfiles/rails4.0.gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal"
|
6
|
-
gem "aruba"
|
7
|
-
gem "coffee-rails"
|
8
|
-
gem "cucumber"
|
9
|
-
gem "jquery-rails"
|
10
|
-
gem "rake"
|
11
|
-
gem "rspec-rails"
|
12
|
-
gem "uglifier"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "rails", "~> 4.0.5"
|
15
|
-
gem "sass-rails"
|
16
|
-
|
17
|
-
gemspec :path => "../"
|