factory_bot_rails 4.10.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS DELETED
@@ -1,30 +0,0 @@
1
- factory_bot_rails versioning is synced with factory_bot releases. For this reason
2
- there might not be any notable changes in new versions of this project.
3
-
4
- 4.10.0 (May 25, 2018)
5
- No notable changes
6
-
7
- 4.8.2 (October 20, 2017)
8
- Rename factory_girl_rails to factory_bot_rails
9
-
10
- 4.7.0 (April 1, 2016)
11
- No notable changes
12
-
13
- 4.6.0 (February 1, 2016)
14
- No notable changes
15
-
16
- 4.5.0 (October 17, 2014)
17
- Improved README
18
-
19
- 4.4.1 (February 26, 2014)
20
- Support Spring
21
-
22
- 4.2.1 (February 8, 2013)
23
- Fix bug when configuring FG and RSpec fixture directory
24
- Remove debugging
25
- Require factory_girl_rails explicitly in generator
26
-
27
- 4.2.0 (January 25, 2013)
28
- Add appraisal and get test suite working reliably with turn gem
29
- Support MiniTest
30
- Allow a custom directory for factories to be specified
data/Rakefile DELETED
@@ -1,24 +0,0 @@
1
- require 'bundler/setup'
2
- require 'cucumber/rake/task'
3
-
4
- Bundler::GemHelper.install_tasks name: 'factory_bot_rails'
5
-
6
- Cucumber::Rake::Task.new(:cucumber) do |t|
7
- t.fork = true
8
- t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
9
- end
10
-
11
- require 'appraisal'
12
-
13
- desc 'Run the test suite'
14
- task :default do |t|
15
- if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
16
- exec 'rake cucumber'
17
- else
18
- Rake::Task['appraise'].execute
19
- end
20
- end
21
-
22
- task :appraise => ['appraisal:install'] do |t|
23
- exec 'rake appraisal'
24
- end
data/bin/setup DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- # Run this script immediately after cloning the codebase.
4
-
5
- # Exit if any subcommand fails
6
- set -e
7
-
8
- # Set up Ruby dependencies via Bundler
9
- bundle install
10
-
11
- # Add binstubs to PATH in ~/.zshenv like this:
12
- # export PATH=".git/safe/../../bin:$PATH"
13
- mkdir -p .git/safe
14
-
15
- # Set up Appraisal to help us test against multiple Rails versions
16
- bundle exec appraisal install
@@ -1,20 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = %q{factory_bot_rails}
3
- s.version = '4.10.0'
4
- s.authors = ["Joe Ferris"]
5
- s.email = %q{jferris@thoughtbot.com}
6
- s.homepage = "http://github.com/thoughtbot/factory_bot_rails"
7
- s.summary = %q{factory_bot_rails provides integration between
8
- factory_bot and rails 3 or newer}
9
- s.description = %q{factory_bot_rails provides integration between
10
- factory_bot and rails 3 or newer (currently just automatic factory definition
11
- loading)}
12
-
13
- s.files = Dir['**/*'].keep_if { |file| File.file?(file) }
14
- s.require_paths = ["lib"]
15
- s.executables = []
16
- s.license = "MIT"
17
-
18
- s.add_runtime_dependency('railties', '>= 3.0.0')
19
- s.add_runtime_dependency('factory_bot', '~> 4.10.0')
20
- end
@@ -1,20 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = %q{factory_girl_rails}
3
- s.version = '4.8.2'
4
- s.authors = ["Joe Ferris"]
5
- s.email = %q{jferris@thoughtbot.com}
6
- s.homepage = "http://github.com/thoughtbot/factory_girl_rails"
7
- s.summary = %q{factory_girl_rails provides integration between
8
- factory_girl and rails 3 or newer}
9
- s.description = %q{factory_girl_rails provides integration between
10
- factory_girl and rails 3 or newer (currently just automatic factory definition
11
- loading)}
12
-
13
- s.files = Dir['**/*'].keep_if { |file| File.file?(file) }
14
- s.require_paths = ["lib"]
15
- s.executables = []
16
- s.license = "MIT"
17
-
18
- s.add_runtime_dependency('railties', '>= 3.0.0')
19
- s.add_runtime_dependency('factory_girl', '~> 4.8.2')
20
- end
@@ -1,132 +0,0 @@
1
- Feature:
2
- In order to not have to manually configure Factory Bot as the Rails testing fixture replacement by using the --fixture-replacement=factory_bot option
3
- I would like the Factory Bot Rails gem to configure Factory Bot as the fixture replacement.
4
-
5
- Background:
6
- Given I successfully run `bundle exec rails new testapp`
7
- And I cd to "testapp"
8
- And I add "factory_bot_rails" from this project as a dependency
9
-
10
- Scenario: Using Factory Bot and Factory Bot Rails with Test Unit generates a factory file and does not generate a fixture file
11
- And I run `bundle install` with a clean environment
12
- And I run `bundle exec rails generate model User name:string` with a clean environment
13
- Then the following files should exist:
14
- | test/factories/users.rb |
15
- And the following files should not exist:
16
- | test/fixtures/users.yml |
17
-
18
- Scenario: Using Factory Bot and Factory Bot Rails with RSpec should generate a factory file
19
- When I add "rspec-rails" as a dependency
20
- And I configure the factories as:
21
- """
22
- config.generators do |g|
23
- g.test_framework :rspec, fixture: true
24
- g.fixture_replacement :factory_bot
25
- end
26
- """
27
- And I run `bundle install` with a clean environment
28
- Then the output should contain "rspec-rails"
29
- And I run `bundle exec rails generate model User name:string` with a clean environment
30
- Then the following files should exist:
31
- | spec/factories/users.rb |
32
- And the following files should not exist:
33
- | spec/fixtures/users.yml |
34
-
35
- Scenario: Using Factory Bot and Factory Bot 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_bot, 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
-
52
- Scenario: Using Factory Bot and Factory Bot Rails does not override a manually-configured factories directory using RSpec
53
- When I add "rspec-rails" as a dependency
54
- And I configure the factories directory as "custom/dir"
55
- And I run `bundle install` with a clean environment
56
- Then the output should contain "rspec-rails"
57
- And I run `bundle exec rails generate model User name:string` with a clean environment
58
- Then the following files should not exist:
59
- | test/factories/users.rb |
60
- | spec/factories/users.rb |
61
- But the following files should exist:
62
- | custom/dir/users.rb |
63
-
64
- Scenario: Using Factory Bot and Factory Bot Rails does not override a manually-configured factories directory using Test::Unit
65
- When I configure the factories directory as "custom/dir"
66
- And I run `bundle install` with a clean environment
67
- And I run `bundle exec rails generate model User name:string` with a clean environment
68
- Then the following files should not exist:
69
- | test/factories/users.rb |
70
- | spec/factories/users.rb |
71
- But the following files should exist:
72
- | custom/dir/users.rb |
73
-
74
- Scenario: Using Factory Bot Rails with MiniTest should generate a factory file
75
- When I run `bundle install` with a clean environment
76
- And I run `bundle exec rails generate model User name:string` with a clean environment
77
- Then the following files should exist:
78
- | test/factories/users.rb |
79
- But the following files should not exist:
80
- | spec/fixtures/users.yml |
81
-
82
- Scenario: Using Factory Bot Rails with MiniTest and a custom directory should generate a factory file
83
- When I configure the factories directory as "custom/dir"
84
- And I run `bundle install` with a clean environment
85
- And I run `bundle exec rails generate model User name:string` with a clean environment
86
- Then the following files should exist:
87
- | custom/dir/users.rb |
88
- But the following files should not exist:
89
- | spec/fixtures/users.yml |
90
-
91
- Scenario: Disable Factory Bot generator
92
- When I configure the factories as:
93
- """
94
- config.generators do |g|
95
- g.factory_bot false
96
- end
97
- """
98
- And I run `bundle install` with a clean environment
99
- And I run `bundle exec rails generate model User name:string` with a clean environment
100
- Then the following files should not exist:
101
- | test/factories/users.rb |
102
- | spec/factories/users.rb |
103
-
104
- Scenario: Use a suffix with the Factory Bot generator
105
- When I add "rspec-rails" as a dependency
106
- When I configure the factories as:
107
- """
108
- config.generators do |g|
109
- g.factory_bot suffix: 'suffix'
110
- end
111
- """
112
- And I run `bundle install` with a clean environment
113
- And I run `bundle exec rails generate model User name:string` with a clean environment
114
- Then the following files should exist:
115
- | spec/factories/users_suffix.rb |
116
- Then the following files should not exist:
117
- | spec/factories/users.rb |
118
-
119
- Scenario: Use a filename_proc with the Factory Bot 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_bot 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 |
@@ -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,5 +0,0 @@
1
- When /^I run `([^"]+)` with a clean environment$/ do |command|
2
- step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'`}
3
- end
4
-
5
- # system({'BUNDLE_GEMFILE' => nil}, "cd tmp/aruba/testapp && #{command} && cd -")
@@ -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
@@ -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'