I am new to rails. Newer to FactoryGirl.
I have a model like this.
class Manifest < ActiveRecord::Base
serialize :scopes, Array
:app_description
:app_name
:app_id
:app_verson
:dev_id
:callback
:manifest_ver
:signed_jwt
:scopes
validates :app_name, presence: true
validates :callback, presence: true
I have a factory like this.
factory(:manifest) do
callback "some callback"
app_name "cool birds"
end
The spec regarding above model is like this.
describe Manifest do
describe "validation" do
describe "of object from fractory" do
it "must be ok" do
FactoryGirl.build(:manifest).should be_valid
end
end
end
end
So I expected this test to pass. But it fails giving this output.
1) Manifest validation of object from fractory must be ok
Failure/Error: FactoryGirl.build(:manifest).should be_valid
expected #<Manifest id: nil, dev_id: nil, app_id: nil, app_description: nil, app_name: "cool birds", app_version: nil, manifest_ver: nil, callback: nil, signed_jwt: nil, scopes: [], created_at: nil, updated_at: nil> to be valid, but got errors: Callback can't be blank
It says Callback can't be blank. It seems FactoryGirl ignores the value for attribute "callback".
when the spec changed to FactoryGirl.build(:manifest, callback: "some callback").should be_valid
it works! The test passes.
FactoryGirl works for any other attribute in my model but "callback". Why? What wrong have I or this attribute named "callback" has done? What should I do to find out the problem.