[rspec-users] uninitialized constant Factory (NameError)

ruby rails lists at ruby-forum.com
Thu Feb 28 13:44:33 UTC 2013

I have installed factory_girl_rails gem in Gemfile for both test as well
as development. And in the password_rest_spec file I have given

require 'spec_helper'
describe "PasswordResets" do
it "emails when user requesting password reset" do
    user = Factory(:user)
    #forget_pwd.userid.should == "ruby"
    #forget_pwd.token.should == "123456"
    #forget_pwd.userkey = "14dd"
      visit auth_index_path
      click_link "Forgot Password"
      fill_in "Email", :with=> user.email
      click_button "Submit"
      current_path.should eq(login_path)
      page.should have_content("Hello Rails")
      last_email.to.should include(user.email)

I have created another file called factories.rb where I have created the
data as below.

Factory.define :user do |f|
  f.sequence(:email) {|n| "foo#{n}@example.com"}
  f.password "Secret"
But when I am running this spec, it is failing and showing the error as
uninitialized constant Factory (NameError).
I have followed exactly as in the railscasts.

Please help

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list