uninitialized constant Factory (NameError)

677 views
Skip to first unread message

Macsig

unread,
Jul 2, 2009, 1:51:04 AM7/2/09
to factory_girl
Hello guys,
I'm trying to set Factory Girl up with Cucumber but I have hard time
to do it.

1- I have installed the gem through
gem install thoughtbot-factory_girl --source http://gems.github.co
[and I can see it (thoughtbot-factory_girl (1.2.1)) listed among my
gems when I run gem list]

2- I have created a file called factories.rb in my spec falder

3- I have added the line below to my cucumber/env file
require "#{Rails.root}/spec/factories"

4- my factories.rb looks like
Factory.define :article do |a|
a.code "9999999"
a.name "foo"
a.unit "bar"
end


When I run cucumber features I get the error below:
uninitialized constant Factory (NameError)
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
dependencies.rb:443:in `load_missing_constant'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
dependencies.rb:80:in `const_missing'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
dependencies.rb:92:in `const_missing'
/SoftwareElement/solution/solutionapp/spec/factories.rb:1
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`polyglot_original_require'
/Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in
`require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
dependencies.rb:158:in `require'
./features/support/env.rb:25
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`polyglot_original_require'
/Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in
`require'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/
cli/main.rb:95:in `require_files'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/
cli/main.rb:104:in `each_lib'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/
cli/main.rb:102:in `each'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/
cli/main.rb:102:in `each_lib'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/
cli/main.rb:95:in `require_files'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/
cli/main.rb:47:in `execute!'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/
cli/main.rb:25:in `execute'
/Users/sigfrid/.gem/ruby/1.8/gems/cucumber-0.3.11/bin/cucumber:9
/usr/bin/cucumber:19:in `load'
/usr/bin/cucumber:19


Am I missing something?

Thanks and have a nice day.

Sig


Dan Croak

unread,
Jul 2, 2009, 1:56:51 AM7/2/09
to factor...@googlegroups.com
Hi Sig,

On Thu, Jul 2, 2009 at 1:51 AM, Macsig<sigb...@gmail.com> wrote:
>
> Hello guys,
> I'm trying to set Factory Girl up with Cucumber but I have hard time
> to do it.
>

> When I run cucumber features I get the error below:
> uninitialized constant Factory (NameError)
>

> Sig

Are you using the latest Cucumber? Do you have a
config/environments/cucumber.rb file? If so, simply add these lines to
it:

require 'rubygems'
require 'factory_girl'

Here's an example:

http://github.com/dancroak/heroku_suspenders/blob/3eddf92cd586e9aa4be5cc8bedd9e89ba44eb8ee/config/environments/cucumber.rb

--
Dan Croak
@Croaky

Macsig

unread,
Jul 2, 2009, 2:52:28 AM7/2/09
to factory_girl
Thanks man.

Have a good 1!

On Jul 1, 10:56 pm, Dan Croak <dcr...@thoughtbot.com> wrote:
> Hi Sig,
>
> On Thu, Jul 2, 2009 at 1:51 AM, Macsig<sigbac...@gmail.com> wrote:
>
> > Hello guys,
> > I'm trying to set Factory Girl up with Cucumber but I have hard time
> > to do it.
>
> > When I run cucumber features I get the error below:
> > uninitialized constant Factory (NameError)
>
> > Sig
>
> Are you using the latest Cucumber? Do you have a
> config/environments/cucumber.rb file? If so, simply add these lines to
> it:
>
> require 'rubygems'
> require 'factory_girl'
>
> Here's an example:
>
> http://github.com/dancroak/heroku_suspenders/blob/3eddf92cd586e9aa4be...
>
> --
> Dan Croak
> @Croaky
Reply all
Reply to author
Forward
0 new messages