I have a Model that looks like this
class Course < ActiveRecord::Base
attr_accessible :name
end
And my factories.rb looks like this
FactoryGirl.define do
factory :course do
name "testname"
end
end
Then when I call FactoryGirl.create(:course) in Cucumber like so:
Given /^there are courses in the database$/ do
FactoryGirl.create(:course)
end
I receive an undefined method error:
undefined method `name=' for #<Course id: nil, created_at: nil, updated_at: nil> (NoMethodError)
It all works fine when I use attr_accessor instead of attr_accessible in the Model, but according to other examples I've found it should work with both. Is this a bug or am I doing something wrong?
Links to examples where they say it should work:
How to create factories with attr_accessible?
https://groups.google.com/forum/#!topic/factory_girl/gjLXp96Acyg
https://gist.github.com/334413/2a0f60a9afbff321d3e96727ec17bab53c484128