diff --git a/features/fixture_replacement_config.feature b/features/fixture_replacement_config.feature index 337f45f..d8833c7 100644 --- a/features/fixture_replacement_config.feature +++ b/features/fixture_replacement_config.feature @@ -7,11 +7,10 @@ Feature: And I cd to "testapp" And I add "factory_girl_rails" from this project as a dependency 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 - And I successfully run `bundle install` - And I successfully run `bundle exec rails generate model User name:string` + And I run `bundle install` with a clean environment + And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should exist: | test/factories/users.rb | 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 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" - 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: | spec/factories/users.rb | 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 When I add "rspec-rails" as a dependency 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" - 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: | test/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 When I configure the factories directory as "custom/dir" - And I successfully run `bundle install` - And I successfully run `bundle exec rails generate model User name:string` + And I run `bundle install` with a clean environment + And I run `bundle exec rails generate model User name:string` with a clean environment Then the following files should not exist: | test/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 When I add "minitest" as a dependency 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" - 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: | test/factories/users.rb | But the following files should not exist: @@ -64,9 +63,9 @@ Feature: When I configure the factories directory as "custom/dir" And I add "minitest" as a dependency 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" - 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: | custom/dir/users.rb | But the following files should not exist: diff --git a/features/generators.feature b/features/generators.feature index a9d1eb4..33512e8 100644 --- a/features/generators.feature +++ b/features/generators.feature @@ -8,22 +8,21 @@ Feature: And I cd to "testapp" And I add "factory_girl_rails" from this project as a dependency 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 - When I successfully run `bundle install` - And I successfully run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl` - And I successfully run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl` + When I run `bundle install` with a clean environment + And I run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl` with a clean environment + 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" 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/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 - 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 successfully run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl` - 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 User name:string --fixture-replacement=factory_girl` with a clean environment + 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" And the output should contain "test/factories/namespaced_users_factory.rb" And the file "test/factories/users_factory.rb" should contain "factory :user do" diff --git a/features/load_definitions.feature b/features/load_definitions.feature index 727b67a..f33201b 100644 --- a/features/load_definitions.feature +++ b/features/load_definitions.feature @@ -5,9 +5,8 @@ Feature: automatically load step definitions And I cd to "testapp" And I add "factory_girl_rails" from this project as a dependency And I configure the database connection for the application - And I reset Bundler environment variable 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: """ class CreateUsers < ActiveRecord::Migration @@ -18,7 +17,7 @@ Feature: automatically load step definitions 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: """ class User < ActiveRecord::Base @@ -45,7 +44,7 @@ Feature: automatically load step definitions 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" Scenario: use factories advertised by railties/engines/3rd-party gems @@ -83,5 +82,5 @@ Feature: automatically load step definitions 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" diff --git a/features/step_definitions/appraisal.rb b/features/step_definitions/appraisal.rb index 8ef59d5..313a5f2 100644 --- a/features/step_definitions/appraisal.rb +++ b/features/step_definitions/appraisal.rb @@ -1,3 +1,5 @@ -When /^I reset Bundler environment variable$/ do - unset_bundler_env_vars +When /^I run `([^"]+)` with a clean environment$/ do |command| + step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil}, "#{command}")'`} end + +# system({'BUNDLE_GEMFILE' => nil}, "cd tmp/aruba/testapp && #{command} && cd -") diff --git a/features/step_definitions/rails_steps.rb b/features/step_definitions/rails_steps.rb index c877b74..27f94b1 100644 --- a/features/step_definitions/rails_steps.rb +++ b/features/step_definitions/rails_steps.rb @@ -31,7 +31,7 @@ end When /^I configure the testing framework to use MiniTest$/ do 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 class Testapp::Application