KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am getting a very strange error when running a spec: Failure/Error: entity = Factory.create(:entity, :name => "Test Entity", :creator => user) ActiveRecord::AssociationTypeMismatch: ::User(#97318850) expected, got User(#92770800) This is the code that results in the above error. Factory is a factory_girl factory. user = Factory(:user, :username => "kai", :email => "xxx@yyy.com", :password => "testing") entity = Factory.create(:entity, :name => "Test Entity", :creator => user) When I use :creator => User.first then everything works as expected. I printed out User.first and user , but see no difference. Any suggestions what the heck is wrong here? Update I also got this error when running this simple request spec describe "Entities" do it "should succeed" do entity = Factory.create(:entity, :name => "Test Entity 1") visit root_path end it "should also succeed" do entity = Factory.create(:entity, :name => "Test Entity 2") property = Factory.create(:property, :entity => entity) end end This time I get Failure/Error: property = Factory.create(:property, :entity => entity) ActiveRecord::AssociationTypeMismatch: Entity(#103620190) expected, got Entity(#96047070) when I delete visit root_path everything works fine (also when running each spec on its own). It just seems to be a problem for request specs. The other specs (model, controller) seems to run fine. I use Capybara 1.0.0.beta1 and RSpec 2.5. What does this number behind the class name mean?
Tags (comma-separated)
Save Edits
Cancel