-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Error with Rails 3.1 rc4, Ruby 1.9: ArgumentError: Not registered #168
Comments
Could you look to see if you're referencing a |
Hi joshua, isn't Factory(:my_factory) the intended use? That's how I use factories all over the place in my tests. ;-) |
well, yes, but not literally. Did you define a :my_factory factory in the factories file? |
This is confusing me. :) The offending factories are defined in factories.rb, of cause. my_factory was just a placeholder. |
factory.rb is supposed to be loaded automatically, right? All used to work fine with rails 2.3. |
Oh, I understand now - I was confused as the error you pasted looked real (I assumed you were referencing a weird factory name). What version of Factory Girl were you using before? Also, what version of Rails are you using? |
I use factory_girl (2.0.2) and factory_girl_rails (1.1.0) with rails 3.1 rc4. |
Before I used factory_girl (1.3.3)and Rails 2.3.5 |
Alright, great. Since you've upgraded to Rails 3, you're going to want to add the |
I only have gem 'factory_girl_rails', "~> 1.1" in my gemfile... |
Do I need to require anything in my testhelper.rb? The factories don't seem to be loaded... |
Hmm. Where are your factories defined? By default, factory_girl_rails is set up to look in factories, spec/factories, and test/factories, either as a ruby file or a directory with *.rb files. Is that not the case? |
They are int test/factories.rb |
no, factory_girl_rails should do this for you. Here's the railtie: https://github.com/thoughtbot/factory_girl_rails/blob/master/lib/factory_girl_rails/railtie.rb To ensure that this is working correctly, can you move factory_girl_rails outside of the test group in your gemfile and run a Rails console? In there, run |
After reading Ryans answer here http://stackoverflow.com/questions/5227081/given-a-typical-rails-3-environment-why-am-i-unable-to-execute-any-tests, I made a slight change to the requires at the top of my test_helper from:
to
and now I get this error straight after running rake test:units, before executing any tests:
On line 4 of factories.rb the user factory is defined:
|
Hmm, I tried that, but since the factory girl upgrade I can't even get my console started anymore, the same error:
|
The new factory_girl syntax looks like this:
Notice the lowercase |
I was getting the following error:
Changing to the new syntax fixed the issue. Thanks! |
Thanks that solved it! Sorry, I got the new syntax wrong during conversion that was the issue. |
I get lots of these errors running my unit tests;
ArgumentError: Not registered: my_factory
gems/ruby-1.9.2-p0/gems/factory_girl-2.0.2/lib/factory_girl/registry.rb:15:in
find' gems/ruby-1.9.2-p0/gems/factory_girl-2.0.2/lib/factory_girl.rb:39:in
factory_by_name'gems/ruby-1.9.2-p0/gems/factory_girl-2.0.2/lib/factory_girl/syntax/vintage.rb:53:in
default_strategy' gems/ruby-1.9.2-p0/gems/factory_girl-2.0.2/lib/factory_girl/syntax/vintage.rb:146:in
Factory'The text was updated successfully, but these errors were encountered: