Reputation: 2889
I have this in factories.rb:
FactoryGirl.create :user do |user|
user.name "test"
user.age "40"
end
and this in my test file:
require 'spec_helper'
describe "FirstTests" do
it "creates a user" do
user=Factory(:user)
end
end
Like always nothing works. Could somebody explain me why I am getting this?
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/factory_girl-4.1.0/lib/factory_girl/registry.rb:24:in `find': Factory not registered: user (ArgumentError)
Everything is there. why I am getting this error?
Upvotes: 1
Views: 157
Reputation: 18784
You are using create
instead of define
FactoryGirl.define do
factory :user do
name "test"
age "40"
end
end
and Factory(:user)
instead of FactoryGirl.create(:user)
, or more simply create(:user)
https://github.com/thoughtbot/factory_girl/wiki/Usage
Upvotes: 5