2011-09-08 12:30:26 -04:00
|
|
|
Feature:
|
2012-12-19 14:46:21 -05:00
|
|
|
In order to not have to manually configure factory girl as the testing fixture replacement by using the --fixture-replacement=factory_girl option as a Rails3 and Factory Girl user
|
|
|
|
I would like the Factory Girl Rails gem to configure Factory Girl as the fixture replacement.
|
2011-09-08 12:30:26 -04:00
|
|
|
|
|
|
|
Background:
|
|
|
|
Given I successfully run `bundle exec rails new testapp`
|
|
|
|
And I cd to "testapp"
|
|
|
|
And I add "factory_girl_rails" from this project as a dependency
|
|
|
|
|
2012-12-19 14:46:21 -05:00
|
|
|
Scenario: Using Factory Girl and Factory Girl Rails with Test Unit generates a factory file and does not generate a fixture file
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle install` with a clean environment
|
|
|
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
2011-09-08 12:30:26 -04:00
|
|
|
Then the following files should exist:
|
|
|
|
| test/factories/users.rb |
|
|
|
|
And the following files should not exist:
|
|
|
|
| test/fixtures/users.yml |
|
|
|
|
|
|
|
|
Scenario: Using Factory Girl and Factory Girl Rails with RSpec should generate a factory file
|
2012-12-19 14:46:21 -05:00
|
|
|
When I add "rspec-rails" as a dependency
|
2013-02-05 09:04:10 -05:00
|
|
|
And I configure the factories as:
|
|
|
|
"""
|
|
|
|
config.generators do |g|
|
|
|
|
g.test_framework :rspec, fixture: true
|
|
|
|
g.fixture_replacement :factory_girl
|
|
|
|
end
|
|
|
|
"""
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle install` with a clean environment
|
2012-12-20 11:54:27 -05:00
|
|
|
Then the output should contain "rspec-rails"
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
2011-09-08 12:30:26 -04:00
|
|
|
Then the following files should exist:
|
|
|
|
| spec/factories/users.rb |
|
|
|
|
And the following files should not exist:
|
|
|
|
| spec/fixtures/users.yml |
|
2012-12-07 11:48:05 -05:00
|
|
|
|
|
|
|
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"
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle install` with a clean environment
|
2012-12-20 11:54:27 -05:00
|
|
|
Then the output should contain "rspec-rails"
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
2012-12-07 11:48:05 -05:00
|
|
|
Then the following files should not exist:
|
|
|
|
| test/factories/users.rb |
|
|
|
|
| spec/factories/users.rb |
|
|
|
|
But the following files should exist:
|
|
|
|
| custom/dir/users.rb |
|
|
|
|
|
2012-12-10 11:29:57 -05:00
|
|
|
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"
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle install` with a clean environment
|
|
|
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
2012-12-10 11:29:57 -05:00
|
|
|
Then the following files should not exist:
|
|
|
|
| test/factories/users.rb |
|
|
|
|
| spec/factories/users.rb |
|
|
|
|
But the following files should exist:
|
|
|
|
| custom/dir/users.rb |
|
|
|
|
|
|
|
|
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
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle install` with a clean environment
|
2012-12-20 11:54:27 -05:00
|
|
|
Then the output should contain "minitest"
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
2012-12-10 11:29:57 -05:00
|
|
|
Then the following files should exist:
|
|
|
|
| test/factories/users.rb |
|
|
|
|
But the following files should not exist:
|
|
|
|
| spec/fixtures/users.yml |
|
|
|
|
|
|
|
|
Scenario: Using Factory Girl and Factory Girl Rails with MiniTest and a custom directory should generate a factory file
|
|
|
|
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
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle install` with a clean environment
|
2012-12-20 11:54:27 -05:00
|
|
|
Then the output should contain "minitest"
|
2012-12-21 11:08:37 -05:00
|
|
|
And I run `bundle exec rails generate model User name:string` with a clean environment
|
2012-12-10 11:29:57 -05:00
|
|
|
Then the following files should exist:
|
|
|
|
| custom/dir/users.rb |
|
|
|
|
But the following files should not exist:
|
|
|
|
| spec/fixtures/users.yml |
|
|
|
|
And the file "test/models/user_test.rb" should contain "MiniTest::Rails::ActiveSupport::TestCase"
|