1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot_rails.git synced 2022-11-09 11:49:18 -05:00
thoughtbot--factory_bot_rails/features/generators.feature
Dan Croak 00cb2eabb1 Test against Rails 3.2, 4.0, 4.1
* Remove gemfiles from version control to match same testing style as
  Clearance and Suspenders.
* MiniTest does not need to be manually included as it is automatically
  included by Rails by default.
* Add spring for Rails 4.1.
* Disable Spring to get specs to pass on Rails 4.1.
* Add therubyrhino for JRuby.
* Remove old references to Rails 3.
* Fix JRuby test where output is "1 runs", not "1 tests".
* Remove Rails 3.0 reference to "turn".
2014-05-27 00:41:24 -07:00

28 lines
1.9 KiB
Gherkin

Feature:
In order to easily generate factory files instead of fixture files when generating models
As a user of Rails and Factory Girl
I would like to use factory_girl_rails generators.
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
Scenario: The factory_girl_rails generators create a factory file for each model that I generate
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 run `bundle install` with a clean environment
And I set the FactoryGirl :suffix option to "factory"
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"
And the file "test/factories/namespaced_users_factory.rb" should contain "factory :namespaced_user, :class => 'Namespaced::User' do"