FactoryGirl: Assigning a value of false to a boolean

Viewed 2428

In my Factory I have a boolean field (evaluated), which I am trying to set to false. I want the field to be required, and always set to either true or false

Model

  validates_presence_of :evaluated

Factory

FactoryGirl.define do
  factory :submission do
    evaluated true
    score 1.5
    ranking 1.5
    submission_type "user"
    .
    .
  end
end

In the test

    it { should validate_presence_of(:evaluated) }

When I run it

     Failure/Error: expect(@submission).to be_valid
   expected #<Submission id: nil, competition_id: 163, user_id: 134, team_id: nil, evaluated: false, score: 1.5, ranking: 1.5, submission_type_cd: "user", withdrawn: true, withdrawn_date: "2016-02-08", created_at: nil, updated_at: nil> to be valid, but got errors: Evaluated can't be blank

If I change the value to true, the test passes

    evaluated true

How can I set up a Factory with false values for Booleans?

1 Answers
Related