mirror of
https://github.com/thoughtbot/factory_bot_rails.git
synced 2022-11-09 11:49:18 -05:00
Instead of modifying the environment, run bundle install in a new process
JRuby does not support setting/unsetting environment variables. Thus, we will launch an entirely new process without the parents env when we run `bundle install` inside the generated rails apps, forcing them to use their own Gemfile, instead of the BUNDLE_GEMFILE setting from the main gem codebase.
This commit is contained in:
parent
2f64464027
commit
51cc9ed402
5 changed files with 27 additions and 28 deletions
|
@ -7,11 +7,10 @@ Feature:
|
||||||
And I cd to "testapp"
|
And I cd to "testapp"
|
||||||
And I add "factory_girl_rails" from this project as a dependency
|
And I add "factory_girl_rails" from this project as a dependency
|
||||||
And I configure the database connection for the application
|
And I configure the database connection for the application
|
||||||
And I reset Bundler environment variable
|
|
||||||
|
|
||||||
Scenario: Using Factory Girl and Factory Girl Rails with Test Unit generates a factory file and does not generate a fixture file
|
Scenario: Using Factory Girl and Factory Girl Rails with Test Unit generates a factory file and does not generate a fixture file
|
||||||
And I successfully run `bundle install`
|
And I run `bundle install` with a clean environment
|
||||||
And I successfully run `bundle exec rails generate model User name:string`
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
||||||
Then the following files should exist:
|
Then the following files should exist:
|
||||||
| test/factories/users.rb |
|
| test/factories/users.rb |
|
||||||
And the following files should not exist:
|
And the following files should not exist:
|
||||||
|
@ -19,9 +18,9 @@ Feature:
|
||||||
|
|
||||||
Scenario: Using Factory Girl and Factory Girl Rails with RSpec should generate a factory file
|
Scenario: Using Factory Girl and Factory Girl Rails with RSpec should generate a factory file
|
||||||
When I add "rspec-rails" as a dependency
|
When I add "rspec-rails" as a dependency
|
||||||
And I successfully run `bundle install`
|
And I run `bundle install` with a clean environment
|
||||||
Then the output should contain "rspec-rails"
|
Then the output should contain "rspec-rails"
|
||||||
And I successfully run `bundle exec rails generate model User name:string`
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
||||||
Then the following files should exist:
|
Then the following files should exist:
|
||||||
| spec/factories/users.rb |
|
| spec/factories/users.rb |
|
||||||
And the following files should not exist:
|
And the following files should not exist:
|
||||||
|
@ -30,9 +29,9 @@ Feature:
|
||||||
Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using RSpec
|
Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using RSpec
|
||||||
When I add "rspec-rails" as a dependency
|
When I add "rspec-rails" as a dependency
|
||||||
And I configure the factories directory as "custom/dir"
|
And I configure the factories directory as "custom/dir"
|
||||||
And I successfully run `bundle install`
|
And I run `bundle install` with a clean environment
|
||||||
Then the output should contain "rspec-rails"
|
Then the output should contain "rspec-rails"
|
||||||
And I successfully run `bundle exec rails generate model User name:string`
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
||||||
Then the following files should not exist:
|
Then the following files should not exist:
|
||||||
| test/factories/users.rb |
|
| test/factories/users.rb |
|
||||||
| spec/factories/users.rb |
|
| spec/factories/users.rb |
|
||||||
|
@ -41,8 +40,8 @@ Feature:
|
||||||
|
|
||||||
Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using Test::Unit
|
Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using Test::Unit
|
||||||
When I configure the factories directory as "custom/dir"
|
When I configure the factories directory as "custom/dir"
|
||||||
And I successfully run `bundle install`
|
And I run `bundle install` with a clean environment
|
||||||
And I successfully run `bundle exec rails generate model User name:string`
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
||||||
Then the following files should not exist:
|
Then the following files should not exist:
|
||||||
| test/factories/users.rb |
|
| test/factories/users.rb |
|
||||||
| spec/factories/users.rb |
|
| spec/factories/users.rb |
|
||||||
|
@ -52,9 +51,9 @@ Feature:
|
||||||
Scenario: Using Factory Girl and Factory Girl Rails with MiniTest should generate a factory file
|
Scenario: Using Factory Girl and Factory Girl Rails with MiniTest should generate a factory file
|
||||||
When I add "minitest" as a dependency
|
When I add "minitest" as a dependency
|
||||||
And I configure the testing framework to use MiniTest
|
And I configure the testing framework to use MiniTest
|
||||||
And I successfully run `bundle install`
|
And I run `bundle install` with a clean environment
|
||||||
Then the output should contain "minitest"
|
Then the output should contain "minitest"
|
||||||
And I successfully run `bundle exec rails generate model User name:string`
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
||||||
Then the following files should exist:
|
Then the following files should exist:
|
||||||
| test/factories/users.rb |
|
| test/factories/users.rb |
|
||||||
But the following files should not exist:
|
But the following files should not exist:
|
||||||
|
@ -64,9 +63,9 @@ Feature:
|
||||||
When I configure the factories directory as "custom/dir"
|
When I configure the factories directory as "custom/dir"
|
||||||
And I add "minitest" as a dependency
|
And I add "minitest" as a dependency
|
||||||
And I configure the testing framework to use MiniTest
|
And I configure the testing framework to use MiniTest
|
||||||
And I successfully run `bundle install`
|
And I run `bundle install` with a clean environment
|
||||||
Then the output should contain "minitest"
|
Then the output should contain "minitest"
|
||||||
And I successfully run `bundle exec rails generate model User name:string`
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
||||||
Then the following files should exist:
|
Then the following files should exist:
|
||||||
| custom/dir/users.rb |
|
| custom/dir/users.rb |
|
||||||
But the following files should not exist:
|
But the following files should not exist:
|
||||||
|
|
|
@ -8,22 +8,21 @@ Feature:
|
||||||
And I cd to "testapp"
|
And I cd to "testapp"
|
||||||
And I add "factory_girl_rails" from this project as a dependency
|
And I add "factory_girl_rails" from this project as a dependency
|
||||||
And I configure the database connection for the application
|
And I configure the database connection for the application
|
||||||
And I reset Bundler environment variable
|
|
||||||
|
|
||||||
Scenario: The factory_girl_rails generators create a factory file for each model that I generate
|
Scenario: The factory_girl_rails generators create a factory file for each model that I generate
|
||||||
When I successfully run `bundle install`
|
When I run `bundle install` with a clean environment
|
||||||
And I successfully run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl`
|
And I run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl` with a clean environment
|
||||||
And I successfully run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl`
|
And I run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl` with a clean environment
|
||||||
Then the output should contain "test/factories/users.rb"
|
Then the output should contain "test/factories/users.rb"
|
||||||
And the output should contain "test/factories/namespaced_users.rb"
|
And the output should contain "test/factories/namespaced_users.rb"
|
||||||
And the file "test/factories/users.rb" should contain "factory :user do"
|
And the file "test/factories/users.rb" should contain "factory :user do"
|
||||||
And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, :class => 'Namespaced::User' do"
|
And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, :class => 'Namespaced::User' do"
|
||||||
|
|
||||||
Scenario: The factory_girl_rails generators create a factory file with a custom name for each model that I generate
|
Scenario: The factory_girl_rails generators create a factory file with a custom name for each model that I generate
|
||||||
When I successfully run `bundle install`
|
When I run `bundle install` with a clean environment
|
||||||
And I set the FactoryGirl :suffix option to "factory"
|
And I set the FactoryGirl :suffix option to "factory"
|
||||||
And I successfully run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl`
|
And I run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl` with a clean environment
|
||||||
And I successfully run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl`
|
And I run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl` with a clean environment
|
||||||
Then the output should contain "test/factories/users_factory.rb"
|
Then the output should contain "test/factories/users_factory.rb"
|
||||||
And the output should contain "test/factories/namespaced_users_factory.rb"
|
And the output should contain "test/factories/namespaced_users_factory.rb"
|
||||||
And the file "test/factories/users_factory.rb" should contain "factory :user do"
|
And the file "test/factories/users_factory.rb" should contain "factory :user do"
|
||||||
|
|
|
@ -5,9 +5,8 @@ Feature: automatically load step definitions
|
||||||
And I cd to "testapp"
|
And I cd to "testapp"
|
||||||
And I add "factory_girl_rails" from this project as a dependency
|
And I add "factory_girl_rails" from this project as a dependency
|
||||||
And I configure the database connection for the application
|
And I configure the database connection for the application
|
||||||
And I reset Bundler environment variable
|
|
||||||
And I comment out gem "turn" from my Gemfile
|
And I comment out gem "turn" from my Gemfile
|
||||||
When I successfully run `bundle install`
|
And I run `bundle install` with a clean environment
|
||||||
And I write to "db/migrate/1_create_users.rb" with:
|
And I write to "db/migrate/1_create_users.rb" with:
|
||||||
"""
|
"""
|
||||||
class CreateUsers < ActiveRecord::Migration
|
class CreateUsers < ActiveRecord::Migration
|
||||||
|
@ -18,7 +17,7 @@ Feature: automatically load step definitions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
When I successfully run `bundle exec rake db:migrate --trace`
|
When I run `bundle exec rake db:migrate --trace` with a clean environment
|
||||||
And I write to "app/models/user.rb" with:
|
And I write to "app/models/user.rb" with:
|
||||||
"""
|
"""
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
|
@ -45,7 +44,7 @@ Feature: automatically load step definitions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
When I successfully run `bundle exec rake test --trace`
|
When I run `bundle exec rake test --trace` with a clean environment
|
||||||
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
||||||
|
|
||||||
Scenario: use factories advertised by railties/engines/3rd-party gems
|
Scenario: use factories advertised by railties/engines/3rd-party gems
|
||||||
|
@ -83,5 +82,5 @@ Feature: automatically load step definitions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
When I successfully run `bundle exec rake test --trace`
|
When I run `bundle exec rake test --trace` with a clean environment
|
||||||
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
When /^I reset Bundler environment variable$/ do
|
When /^I run `([^"]+)` with a clean environment$/ do |command|
|
||||||
unset_bundler_env_vars
|
step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil}, "#{command}")'`}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# system({'BUNDLE_GEMFILE' => nil}, "cd tmp/aruba/testapp && #{command} && cd -")
|
||||||
|
|
|
@ -31,7 +31,7 @@ end
|
||||||
|
|
||||||
When /^I configure the testing framework to use MiniTest$/ do
|
When /^I configure the testing framework to use MiniTest$/ do
|
||||||
append_to_file('Gemfile', %{gem "minitest-rails", :group => [:development, :test]\n})
|
append_to_file('Gemfile', %{gem "minitest-rails", :group => [:development, :test]\n})
|
||||||
step %{I successfully run `rails generate mini_test:install`}
|
step %{I run `rails generate mini_test:install` with a clean environment}
|
||||||
|
|
||||||
append_to_file File.join('config', 'application.rb'), <<-END
|
append_to_file File.join('config', 'application.rb'), <<-END
|
||||||
class Testapp::Application
|
class Testapp::Application
|
||||||
|
|
Loading…
Add table
Reference in a new issue