factory_bot_rails 4.10.0 → 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS +3 -0
- data/README.md +23 -12
- metadata +6 -27
- data/Appraisals +0 -21
- data/Gemfile +0 -20
- data/Gemfile.lock +0 -144
- data/Rakefile +0 -24
- data/bin/setup +0 -16
- data/factory_bot_rails.gemspec +0 -20
- data/factory_girl_rails.gemspec +0 -20
- data/features/fixture_replacement_config.feature +0 -132
- data/features/generators.feature +0 -54
- data/features/load_definitions.feature +0 -85
- data/features/step_definitions/appraisal.rb +0 -5
- data/features/step_definitions/rails_steps.rb +0 -42
- data/features/support/env.rb +0 -21
- data/gemfiles/rails3.2.gemfile +0 -22
- data/gemfiles/rails3.2.gemfile.lock +0 -186
- data/gemfiles/rails4.1.gemfile +0 -23
- data/gemfiles/rails4.1.gemfile.lock +0 -181
- data/gemfiles/rails4.2.gemfile +0 -21
- data/gemfiles/rails4.2.gemfile.lock +0 -189
- data/gemfiles/rails5.0.gemfile +0 -22
- data/gemfiles/rails5.0.gemfile.lock +0 -156
data/features/generators.feature
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
Feature:
|
2
|
-
In order to easily generate factory files instead of fixture files when generating models
|
3
|
-
As a user of Rails and Factory Bot
|
4
|
-
I would like to use factory_bot_rails generators.
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given I successfully run `bundle exec rails new testapp`
|
8
|
-
And I cd to "testapp"
|
9
|
-
And I add "factory_bot_rails" from this project as a dependency
|
10
|
-
|
11
|
-
Scenario: The factory_bot_rails generators create a factory file for each model if there is not a factories.rb file
|
12
|
-
When I run `bundle install` with a clean environment
|
13
|
-
And I run `bundle exec rails generate model User name:string age:integer` with a clean environment
|
14
|
-
And I run `bundle exec rails generate model Namespaced::User name:string` with a clean environment
|
15
|
-
Then the output should contain "test/factories/users.rb"
|
16
|
-
And the output should contain "test/factories/namespaced_users.rb"
|
17
|
-
And the file "test/factories/users.rb" should contain exactly:
|
18
|
-
"""
|
19
|
-
FactoryBot.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_bot_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
|
-
FactoryBot.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
|
-
FactoryBot.define do
|
40
|
-
factory :user do
|
41
|
-
name "MyString"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
"""
|
45
|
-
|
46
|
-
Scenario: The factory_bot_rails generators does not create a factory file for each model if there is a factories.rb file in the test directory
|
47
|
-
When I run `bundle install` with a clean environment
|
48
|
-
And I write to "test/factories.rb" with:
|
49
|
-
"""
|
50
|
-
FactoryBot.define do
|
51
|
-
end
|
52
|
-
"""
|
53
|
-
And I run `bundle exec rails generate model User name:string` with a clean environment
|
54
|
-
Then the file "test/factories.rb" should contain "factory :user do"
|
@@ -1,85 +0,0 @@
|
|
1
|
-
Feature: automatically load step definitions
|
2
|
-
|
3
|
-
Background:
|
4
|
-
When I successfully run `bundle exec rails new testapp`
|
5
|
-
And I cd to "testapp"
|
6
|
-
And I add "factory_bot_rails" from this project as a dependency
|
7
|
-
And I add "test-unit" as a dependency
|
8
|
-
And I run `bundle install` with a clean environment
|
9
|
-
And I write to "db/migrate/1_create_users.rb" with:
|
10
|
-
"""
|
11
|
-
class CreateUsers < ActiveRecord::Migration
|
12
|
-
def self.up
|
13
|
-
create_table :users do |t|
|
14
|
-
t.string :name
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
"""
|
19
|
-
When I run `bundle exec rake db:migrate` with a clean environment
|
20
|
-
And I write to "app/models/user.rb" with:
|
21
|
-
"""
|
22
|
-
class User < ActiveRecord::Base
|
23
|
-
end
|
24
|
-
"""
|
25
|
-
|
26
|
-
Scenario: generate a Rails application and use factory definitions
|
27
|
-
When I write to "test/factories.rb" with:
|
28
|
-
"""
|
29
|
-
FactoryBot.define do
|
30
|
-
factory :user do
|
31
|
-
name "Frank"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
"""
|
35
|
-
When I write to "test/unit/user_test.rb" with:
|
36
|
-
"""
|
37
|
-
require 'test_helper'
|
38
|
-
|
39
|
-
class UserTest < ActiveSupport::TestCase
|
40
|
-
test "use factory" do
|
41
|
-
user = FactoryBot.create(:user)
|
42
|
-
assert_equal 'Frank', user.name
|
43
|
-
end
|
44
|
-
end
|
45
|
-
"""
|
46
|
-
When I run `bundle exec rake test` with a clean environment
|
47
|
-
Then the output should contain "1 assertions, 0 failures, 0 errors"
|
48
|
-
|
49
|
-
Scenario: use factories advertised by railties/engines/3rd-party gems
|
50
|
-
When I append to "config/application.rb" with:
|
51
|
-
"""
|
52
|
-
require File.expand_path('../../lib/some_railtie/railties.rb', __FILE__)
|
53
|
-
"""
|
54
|
-
When I write to "lib/some_railtie/railties.rb" with:
|
55
|
-
"""
|
56
|
-
module SomeRailtie
|
57
|
-
class Railtie < ::Rails::Engine
|
58
|
-
|
59
|
-
initializer "some_railtie.factories", :after => "factory_bot.set_factory_paths" do
|
60
|
-
FactoryBot.definition_file_paths << File.expand_path('../factories', __FILE__)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
"""
|
65
|
-
When I write to "lib/some_railtie/factories.rb" with:
|
66
|
-
"""
|
67
|
-
FactoryBot.define do
|
68
|
-
factory :factory_from_some_railtie, class: 'User' do
|
69
|
-
name 'Artem'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
"""
|
73
|
-
When I write to "test/unit/user_test.rb" with:
|
74
|
-
"""
|
75
|
-
require 'test_helper'
|
76
|
-
|
77
|
-
class UserTest < ActiveSupport::TestCase
|
78
|
-
test "use factory of some_railtie" do
|
79
|
-
user = FactoryBot.create(:factory_from_some_railtie)
|
80
|
-
assert_equal 'Artem', user.name
|
81
|
-
end
|
82
|
-
end
|
83
|
-
"""
|
84
|
-
When I run `bundle exec rake test` with a clean environment
|
85
|
-
Then the output should contain "1 assertions, 0 failures, 0 errors"
|
@@ -1,42 +0,0 @@
|
|
1
|
-
When /^I add "([^"]+)" from this project as a dependency$/ do |gem_name|
|
2
|
-
append_to_file('Gemfile', %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n})
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I add "([^"]+)" as a dependency$/ do |gem_name|
|
6
|
-
append_to_file('Gemfile', %{gem "#{gem_name}"\n})
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^I print out "([^"]*)"$/ do |path|
|
10
|
-
in_current_dir do
|
11
|
-
File.open(path, 'r') do |f|
|
12
|
-
puts f.inspect
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
When /^I configure the factories as:$/ do |string|
|
18
|
-
append_to_file File.join('config', 'application.rb'), <<-END
|
19
|
-
class Testapp::Application
|
20
|
-
#{string}
|
21
|
-
end
|
22
|
-
END
|
23
|
-
end
|
24
|
-
|
25
|
-
When /^I configure the factories directory as "([^"]+)"$/ do |factory_dir|
|
26
|
-
append_to_file File.join('config', 'application.rb'), <<-END
|
27
|
-
class Testapp::Application
|
28
|
-
config.generators do |g|
|
29
|
-
g.fixture_replacement :factory_bot, :dir => "#{factory_dir}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
END
|
33
|
-
end
|
34
|
-
|
35
|
-
When /^I comment out gem "([^"]*)" from my Gemfile$/ do |gem_name|
|
36
|
-
in_current_dir do
|
37
|
-
content = File.read('Gemfile')
|
38
|
-
File.open('Gemfile', 'w') do |f|
|
39
|
-
f.write content.sub(/gem ['"]#{gem_name}/, '#\1')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'aruba/cucumber'
|
2
|
-
|
3
|
-
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
|
4
|
-
|
5
|
-
Aruba.configure do |config|
|
6
|
-
config.exit_timeout = Integer ENV.fetch("ARUBA_TIMEOUT") { 120 }
|
7
|
-
end
|
8
|
-
|
9
|
-
Aruba.configure do |config|
|
10
|
-
config.before_cmd do |cmd|
|
11
|
-
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
|
12
|
-
|
13
|
-
java_options = ENV['JAVA_OPTS']
|
14
|
-
|
15
|
-
if 1.size == 4 # 4 for 32 bit java, 8 for 64 bit java.
|
16
|
-
set_env('JAVA_OPTS', "-d32 #{java_options}")
|
17
|
-
else
|
18
|
-
set_env('JAVA_OPTS', "-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end if RUBY_PLATFORM == 'java'
|
data/gemfiles/rails3.2.gemfile
DELETED
@@ -1,22 +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", "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", "~> 3.2.21"
|
20
|
-
gem "sass-rails"
|
21
|
-
|
22
|
-
gemspec :name => "factory_bot_rails", :path => "../"
|
@@ -1,186 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
factory_bot_rails (4.10.0)
|
5
|
-
factory_bot (~> 4.10.0)
|
6
|
-
railties (>= 3.0.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actionmailer (3.2.22.5)
|
12
|
-
actionpack (= 3.2.22.5)
|
13
|
-
mail (~> 2.5.4)
|
14
|
-
actionpack (3.2.22.5)
|
15
|
-
activemodel (= 3.2.22.5)
|
16
|
-
activesupport (= 3.2.22.5)
|
17
|
-
builder (~> 3.0.0)
|
18
|
-
erubis (~> 2.7.0)
|
19
|
-
journey (~> 1.0.4)
|
20
|
-
rack (~> 1.4.5)
|
21
|
-
rack-cache (~> 1.2)
|
22
|
-
rack-test (~> 0.6.1)
|
23
|
-
sprockets (~> 2.2.1)
|
24
|
-
activemodel (3.2.22.5)
|
25
|
-
activesupport (= 3.2.22.5)
|
26
|
-
builder (~> 3.0.0)
|
27
|
-
activerecord (3.2.22.5)
|
28
|
-
activemodel (= 3.2.22.5)
|
29
|
-
activesupport (= 3.2.22.5)
|
30
|
-
arel (~> 3.0.2)
|
31
|
-
tzinfo (~> 0.3.29)
|
32
|
-
activeresource (3.2.22.5)
|
33
|
-
activemodel (= 3.2.22.5)
|
34
|
-
activesupport (= 3.2.22.5)
|
35
|
-
activesupport (3.2.22.5)
|
36
|
-
i18n (~> 0.6, >= 0.6.4)
|
37
|
-
multi_json (~> 1.0)
|
38
|
-
appraisal (2.2.0)
|
39
|
-
bundler
|
40
|
-
rake
|
41
|
-
thor (>= 0.14.0)
|
42
|
-
arel (3.0.3)
|
43
|
-
aruba (0.14.5)
|
44
|
-
childprocess (>= 0.6.3, < 0.10.0)
|
45
|
-
contracts (~> 0.9)
|
46
|
-
cucumber (>= 1.3.19)
|
47
|
-
ffi (~> 1.9.10)
|
48
|
-
rspec-expectations (>= 2.99)
|
49
|
-
thor (~> 0.19)
|
50
|
-
builder (3.0.4)
|
51
|
-
childprocess (0.9.0)
|
52
|
-
ffi (~> 1.0, >= 1.0.11)
|
53
|
-
coffee-rails (3.2.2)
|
54
|
-
coffee-script (>= 2.2.0)
|
55
|
-
railties (~> 3.2.0)
|
56
|
-
coffee-script (2.4.1)
|
57
|
-
coffee-script-source
|
58
|
-
execjs
|
59
|
-
coffee-script-source (1.12.2)
|
60
|
-
concurrent-ruby (1.0.5)
|
61
|
-
contracts (0.16.0)
|
62
|
-
cucumber (1.3.19)
|
63
|
-
builder (>= 2.1.2)
|
64
|
-
diff-lcs (>= 1.1.3)
|
65
|
-
gherkin (~> 2.12)
|
66
|
-
multi_json (>= 1.7.5, < 2.0)
|
67
|
-
multi_test (>= 0.1.2)
|
68
|
-
diff-lcs (1.3)
|
69
|
-
erubis (2.7.0)
|
70
|
-
execjs (2.7.0)
|
71
|
-
factory_bot (4.10.0)
|
72
|
-
activesupport (>= 3.0.0)
|
73
|
-
ffi (1.9.23)
|
74
|
-
gherkin (2.12.2)
|
75
|
-
multi_json (~> 1.3)
|
76
|
-
hike (1.2.3)
|
77
|
-
i18n (0.9.5)
|
78
|
-
concurrent-ruby (~> 1.0)
|
79
|
-
journey (1.0.4)
|
80
|
-
jquery-rails (3.1.5)
|
81
|
-
railties (>= 3.0, < 5.0)
|
82
|
-
thor (>= 0.14, < 2.0)
|
83
|
-
json (1.8.6)
|
84
|
-
mail (2.5.5)
|
85
|
-
mime-types (~> 1.16)
|
86
|
-
treetop (~> 1.4.8)
|
87
|
-
mime-types (1.25.1)
|
88
|
-
multi_json (1.13.1)
|
89
|
-
multi_test (0.1.2)
|
90
|
-
polyglot (0.3.5)
|
91
|
-
power_assert (1.1.1)
|
92
|
-
rack (1.4.7)
|
93
|
-
rack-cache (1.7.2)
|
94
|
-
rack (>= 0.4)
|
95
|
-
rack-ssl (1.3.4)
|
96
|
-
rack
|
97
|
-
rack-test (0.6.3)
|
98
|
-
rack (>= 1.0)
|
99
|
-
rails (3.2.22.5)
|
100
|
-
actionmailer (= 3.2.22.5)
|
101
|
-
actionpack (= 3.2.22.5)
|
102
|
-
activerecord (= 3.2.22.5)
|
103
|
-
activeresource (= 3.2.22.5)
|
104
|
-
activesupport (= 3.2.22.5)
|
105
|
-
bundler (~> 1.0)
|
106
|
-
railties (= 3.2.22.5)
|
107
|
-
railties (3.2.22.5)
|
108
|
-
actionpack (= 3.2.22.5)
|
109
|
-
activesupport (= 3.2.22.5)
|
110
|
-
rack-ssl (~> 1.3.2)
|
111
|
-
rake (>= 0.8.7)
|
112
|
-
rdoc (~> 3.4)
|
113
|
-
thor (>= 0.14.6, < 2.0)
|
114
|
-
rake (12.3.1)
|
115
|
-
rb-fsevent (0.10.3)
|
116
|
-
rb-inotify (0.9.10)
|
117
|
-
ffi (>= 0.5.0, < 2)
|
118
|
-
rdoc (3.12.2)
|
119
|
-
json (~> 1.4)
|
120
|
-
rspec-core (3.7.1)
|
121
|
-
rspec-support (~> 3.7.0)
|
122
|
-
rspec-expectations (3.7.0)
|
123
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
-
rspec-support (~> 3.7.0)
|
125
|
-
rspec-mocks (3.7.0)
|
126
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
127
|
-
rspec-support (~> 3.7.0)
|
128
|
-
rspec-rails (3.7.2)
|
129
|
-
actionpack (>= 3.0)
|
130
|
-
activesupport (>= 3.0)
|
131
|
-
railties (>= 3.0)
|
132
|
-
rspec-core (~> 3.7.0)
|
133
|
-
rspec-expectations (~> 3.7.0)
|
134
|
-
rspec-mocks (~> 3.7.0)
|
135
|
-
rspec-support (~> 3.7.0)
|
136
|
-
rspec-support (3.7.1)
|
137
|
-
sass (3.5.6)
|
138
|
-
sass-listen (~> 4.0.0)
|
139
|
-
sass-listen (4.0.0)
|
140
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
141
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
142
|
-
sass-rails (3.2.6)
|
143
|
-
railties (~> 3.2.0)
|
144
|
-
sass (>= 3.1.10)
|
145
|
-
tilt (~> 1.3)
|
146
|
-
sprockets (2.2.3)
|
147
|
-
hike (~> 1.2)
|
148
|
-
multi_json (~> 1.0)
|
149
|
-
rack (~> 1.0)
|
150
|
-
tilt (~> 1.1, != 1.3.0)
|
151
|
-
sqlite3 (1.3.13)
|
152
|
-
test-unit (3.2.8)
|
153
|
-
power_assert
|
154
|
-
thor (0.20.0)
|
155
|
-
tilt (1.4.1)
|
156
|
-
treetop (1.4.15)
|
157
|
-
polyglot
|
158
|
-
polyglot (>= 0.3.1)
|
159
|
-
tzinfo (0.3.54)
|
160
|
-
uglifier (4.1.10)
|
161
|
-
execjs (>= 0.3.0, < 3)
|
162
|
-
|
163
|
-
PLATFORMS
|
164
|
-
ruby
|
165
|
-
|
166
|
-
DEPENDENCIES
|
167
|
-
activerecord-jdbcsqlite3-adapter
|
168
|
-
appraisal
|
169
|
-
aruba
|
170
|
-
coffee-rails
|
171
|
-
cucumber (= 1.3.19)
|
172
|
-
factory_bot_rails!
|
173
|
-
jdbc-sqlite3
|
174
|
-
jquery-rails
|
175
|
-
jruby-openssl
|
176
|
-
rails (~> 3.2.21)
|
177
|
-
rake
|
178
|
-
rspec-rails
|
179
|
-
sass-rails
|
180
|
-
sqlite3
|
181
|
-
test-unit
|
182
|
-
therubyrhino
|
183
|
-
uglifier
|
184
|
-
|
185
|
-
BUNDLED WITH
|
186
|
-
1.16.1
|
data/gemfiles/rails4.1.gemfile
DELETED
@@ -1,23 +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", "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.1.9"
|
20
|
-
gem "sass-rails"
|
21
|
-
gem "spring"
|
22
|
-
|
23
|
-
gemspec :name => "factory_bot_rails", :path => "../"
|