Re: Rails 3, RSpec, Factory Girl results in NameError: uninitialized constant

Heinz Strunk
Sun, 16 Jan 2011 13:45:44 -0000

I just tried the console and same error occurs:
ruby-1.9.2-p136 :016 > Factory.define :blah do |f| f.name "dasd";
f.email "blsdfkj-m9b4e1/XOJA@public.gmane.org" end
 => #<Factory:0x82d2ac8 @factory_name=:blah, @options={},
@attributes=[#<Factory::Attribute::Static:0x82ccb00 @name=:name,
@value="dasd">, #<Factory::Attribute::Static:0x82cc7cc
@name=:email,
@value="blsdfkj-m9b4e1/XOJA@public.gmane.org">]>
ruby-1.9.2-p136 :017 > Factory(:blah)
NameError: uninitialized constant Blah
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/backward_compatibility.rb:20:in
`const_missing''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:355:in
`const_get''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:355:in
`block in class_for''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:354:in
`each''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:354:in
`inject''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:354:in
`class_for''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:71:in
`build_class''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:321:in
`run''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:273:in
`create''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl/factory.rb:304:in
`default_strategy''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/factory_girl-1.3.3/lib/factory_girl.rb:20:in
`Factory''
        from (irb):17
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.0/lib/rails/commands/console.rb:44:in
`start''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.0/lib/rails/commands/console.rb:8:in
`start''
        from
/usr/local/rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.0/lib/rails/commands.rb:23:in
`<top (required)>''
        from script/rails:6:in `require''
from script/rails:6:in ` ''ruby-1.9.2-p136 :018 >

...what''s wrong with this girl?