Having some issues with factory_girl and bundler

Hi All

Need some brilliants minds here :slight_smile:

I’m using Rails 2.3.8 & ruby 1.8 (I know, I know… )
I’ve move my gems from .gems to Bundler, but I’m having some issues with
Factory_girl when I rake spec
“uninitialized constant Factory”

I’m following the instructions from Gem Bundler – Manage your Ruby gems.
Basically:

  • grab all config.gem and place them into Gemfile
  • bundle install
  • check Gemfile.lock in my repository … etc

I even tried with a new dummy app from scratch and got the samething…
/script/console test
Loading test environment (Rails 2.3.8)

Factory
NameError: uninitialized constant Factory
from
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in
load_missing_constant' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in const_missing’
from
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in
`const_missing’
from (irb):1
require ‘factory_girl’
=> true

My Gemfile looks like this

source :gemcutter

gem “rails”, “2.3.8”
gem “memcached-northscale”
gem “uuidtools”, “>= 1.0.2”
gem “json”, “>= 1.2.4”
gem “nokogiri”, “>= 1.4.0”
gem “tzinfo”, “>=0.3.5”
gem “SystemTimer”, “>=1.1.3”
gem “will_paginate”, “>= 2.3.11”
gem “taf2-curb”, “>=0.3.5.0”
gem “pg”
gem “hoptoad_notifier”
gem “treetop”
gem “term-ansicolor”
gem “diff-lcs”

group :development, :test do
gem “factory_girl”, :require => 'factory Note: last tried… Placing
it
outside of the groups, throw the same error…
gem “rspec”
gem “rspec-rails”, “>= 1.3.2”
gem “webrat”, “>=0.5.3”
gem “ruby-debug”
end

Any ideas? Suggestions?
BTW Samething is happening with will_paginate

Thanks a lot for your help. You guys rock!

On Sep 27, 4:11 pm, Carmen Díaz Echauri [email protected] wrote:

Basically:
NameError: uninitialized constant Factory

gem “json”, “>= 1.2.4”

BTW Samething is happening with will_paginate

Thanks a lot for your help. You guys rock!


Carmen


rspec-users mailing list
[email protected]://rubyforge.org/mailman/listinfo/rspec-users

Try:

gem ‘factory_girl_rails’

On Mon, Sep 27, 2010 at 5:05 PM, Justin Ko [email protected] wrote:

“uninitialized constant Factory”

Try:

gem ‘factory_girl_rails’

According to GitHub - thoughtbot/factory_bot: A library for setting up Ruby objects as test data., that’s only for
Rails 3: “If you want to use factory_girl with Rails 3, see
github.com/thoughtbot/factory_girl_rails.

I’ve been working on moving a Rails 2.3.9 app to Bundler 1.0.0 from a
custom
solution. The app uses factory_girl with rspec and cucumber, and all the
specs and cukes run successfully. At the bottom of
config/environments/cucumber.rb, I have require ‘factory_girl’. I don’t
have
any similar requires in config/environments/test.rb or in
spec/spec_helper.rb.

Here’s the current Gemfile:

source “http://rubygems.org

gem “rails”, “~> 2.3.9”

gem “rake”, “~> 0.8.7”
gem “haml”, “~> 3.0.18”
gem “fastercsv”, “~> 1.5.3”
gem “will_paginate”, “~> 2.3.12”

gem “rspec”, “~> 1.3.0”, :group => [:test, :cucumber]
gem “rspec-rails”, “~> 1.3.2”, :group => [:test, :cucumber]
gem “capybara”, “~> 0.3.8”, :group => [:cucumber]
gem “cucumber”, “~> 0.7.3”, :group => [:cucumber]
gem “cucumber-rails”, “~> 0.3.1”, :group => [:cucumber]
gem “gherkin”, “~> 1.0.30”, :group => [:cucumber]
gem “database_cleaner”, “~> 0.5.0”, :group => [:cucumber]
gem “dupe”, “~> 0.5.1”, :group => [:test, :cucumber]
gem “factory_girl”, “~> 1.2.4”, :group => [:test, :cucumber]

platforms :jruby do
gem “jruby-openssl”, “~> 0.7.1”
gem “jruby-rack”, “~> 1.0.3”
gem “warbler”, “~> 1.0.1”
gem “flying_saucer”, “~> 0.8.0”

group :db do
gem “jdbc-mysql”, “~> 5.0.4”
gem “activerecord-jdbc-adapter”, “~> 0.9.2”
gem “activerecord-jdbcmysql-adapter”, “~> 0.9.2”
end

end

Note that I’m not using the :require option with gem “factory_girl.”

Since I don’t have any ideas about your specific errors and I have to
head
out to an appointment, I hope all of this helps.

Regards,
Craig

On Sep 27, 6:22 pm, Craig D. [email protected] wrote:

“uninitialized constant Factory”

gem “cucumber”, “~> 0.7.3”, :group => [:cucumber]
gem “flying_saucer”, “~> 0.8.0”

Since I don’t have any ideas about your specific errors and I have to head
out to an appointment, I hope all of this helps.

Regards,
Craig


rspec-users mailing list
[email protected]://rubyforge.org/mailman/listinfo/rspec-users

My only guess is he is calling Factory somewhere where it is not
available.