Mike F.
Mike F.

Reputation: 69

Rails test database values do not match fixture values

This seems like a very strange problem to me. I have a table which contained a boolean value field. I changed that field to be a string since I now want more possible values than just yes or no. I ran the migration and reran the tests. The database table structures show that the field type has been changed to a varchar(255). But every time I run the test, the database field values are still showing 'f' or 't'. But in my fixture file, I am now setting the values to "No" or "Yes":

one:
  value: No

two:
  value: Yes

I've tried purging the database and rerunning the test. But nothing helps. I have no idea where boolean values are coming from since I changed the type. I can't think of anything else that needs to be cleared out. I'm sure there is something simple I'm forgetting to do but I don't see it. If more information is needed to answer this, please let me know.

I'm running rails 4.1.5 with ruby 2.1.4. I'm running the tests using SQLite.

Upvotes: 0

Views: 227

Answers (1)

Peter Goldstein
Peter Goldstein

Reputation: 4555

The values Yes and No are interpreted as booleans in Yaml files. Try changing it to:

one:
  value: "No"

two:
  value: "Yes"

Upvotes: 3

Related Questions