I am using the cucumber step definitons provided by factory girl and I can not get something to work here.
First of all, here are the involved factories:
Factory.define :user do |u|
u.name {|n| "User#{n}" }
u.first_name {|n| "FirstName#{n}"}
u.last_name {|n| "LastName#{n}"}
u.password 'please'
u.password_confirmation 'please'
end
Factory.define :lecture do |l|
l.name {|n| "Lecture#{n}"}
l.abbreviation {|n| "lec#{n}"}
l.association :admin, factory: :user
end
Here is the step I am trying to execute:
And the following Lecture exists:
| Name | Abbreviation |
| Informatik A - Algorithmen und Datenstrukturen | ainf |
I am getting this error message and have absolutely NO idea where it comes from:
User(#42819220) expected, got User(#43753000) (ActiveRecord::AssociationTypeMismatch)
features/lectures/ui.feature:11:in `And the following Lecture exists:'
And here are my model definitions:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :rememberable, :trackable
# Setup accessible (or protected) attributes for your model
attr_accessible :name, :password, :password_confirmation, :remember_me, :first_name, :last_name
validates_uniqueness_of :name
has_many :administrated_lectures, class_name: "Lecture", foreign_key: "admin_id", dependent: :nullify
end
class Lecture < ActiveRecord::Base
validates_uniqueness_of :name
validates_uniqueness_of :abbreviation
scope :ordered, order("name")
belongs_to :admin, class_name: "User"
end
I am using this with spork btw.
Kind regards,
Nils
Oh, damn. Got it. I set
cache_classestofalsesomewhere in the past because proper class reloading did not work for some reason. Just made ittrueagain, and now it works. :/