-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
factories generated in 'test/' not 'spec/' with RSpec in 4.2.0 #88
Comments
Thanks for reporting this @DanielKehoe; I'll dig in to this tomorrow and see if I can get it fixed. I just recently pulled in some code to handle a certain edge case; my guess is that it broke this; sorry about that! I'll update the ticket once I find a fix. |
@DanielKehoe could you update your Gemfile to point to the GitHub repository and ensure that it works? This should fix it but I'd like to verify in your project since you were having issues. Thanks! |
@DanielKehoe Closing this for now - I cut version 4.2.1 of the gem which should fix this, but please reopen the ticket if you're still seeing issues. Thanks! |
Just learned this the hard way: You can get the same problem by having |
@taavo Having the same problem, thanks 👍 |
@taavo Thanks for pointing it out. |
@taavo good spot so recommending to do |
Recommends adding to `factory_girl_rails` to both your `:test` and `:development` groups so generators will work in development. As per issue thoughtbot#88 thoughtbot#88
The behavior of factory_girl_rails has changed from 4.1.0 to 4.2.0 when used with RSpec.
Prior to 4.2.0, specifying a generator in config/application.rb would create a factory file in the 'spec/factories' directory.
After updating to factory_girl_rails 4.2.0, the generator creates a factory file in the 'test/factories' directory.
The expected behavior can be forced by specifying the directory like this:
I don't know whether the change in configuration requirements is intentional or whether 4.2.0 introduced an anomaly.
Here are the steps to reproduce the behavior.
$ rvm gemset create fgtest
$ rvm gemset use fgtest
$ gem list
*** LOCAL GEMS ***
bundler (1.2.3)
rake (10.0.3)
rubygems-bundler (1.1.0)
rubygems-update (1.8.25)
rvm (1.11.3.6, 1.11.3.5)
$ gem install rails
$ rails new myapp
$ cd myapp
add factory_girl_rails 4.1.0 to the Gemfile:
gem "factory_girl_rails", "4.1.0", :group = [:development, :test]
$ bundle install
$ rails generate model foo
creates test/factories/foos.rb (expected behavior)
add rspec-rails to the Gemfile:
gem "rspec-rails", ">= 2.12.2", :group = [:development, :test]
$ bundle install
edit config/application.rb to add:
$ rails generate model bar
creates spec/factories/bars.rb (expected behavior with factory_girl_rails 4.1.0)
update Gemfile from factory_girl_rails 4.1.0 to 4.2.0
gem "factory_girl_rails", "4.2.0", :group = [:development, :test]
$ bundle update
$ rails generate model baz
creates test/factories/bazs.rb (unexpected behavior with factory_girl_rails 4.2.0)
$ rails generate model baz
invoke active_record
create db/migrate/20130130201940_create_bazs.rb
create app/models/baz.rb
invoke rspec
create spec/models/baz_spec.rb
invoke factory_girl
create test/factories/bazs.rb
edit config/application.rb to add:
$ rails generate model qux
creates spec/factories/quxes.rb (expected behavior)
The text was updated successfully, but these errors were encountered: