3

I have this validation in my model:

validates_inclusion_of :imported, :in => [true, false]

but still allows Strings and Fixnums. This Shoulda macro returns 2 failures:

should_not_allow_values_for :imported, "blah", 42

and I've checked that the macro isn't at fault by doing this in a test:

@item.imported = 42
assert !@item.save

and I get this failure:

<false> is not true.

Here is the relevant line in schema.rb:

t.boolean  "imported"
Tunaki
  • 132,869
  • 46
  • 340
  • 423
solidcell
  • 7,639
  • 4
  • 40
  • 59

1 Answers1

5

The question is outdated now, so I hope you found an answer, but here's the comprehensive story on another question I answered:

Rails: Validating inclusion of a boolean fails tests

Community
  • 1
  • 1
Keith Gaddis
  • 4,113
  • 23
  • 20
  • 1
    Thanks for the response. I'm sure someone doing a search and coming across this will very much appreciate it. – solidcell Mar 03 '11 at 17:14