Reputation: 39
Fixtures when using Rails (My environment Rails 4.2)
Why when running a test, why does it error when a fixture exists but there isn't a table with the same name? And why does the fixture require to have a matching column in the table?
Example 1: (table does not exist)
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: joes: DELETE FROM "joes"
Example 2: (table exists, but column does not)
ActiveRecord::Fixture::FixtureError: table "products" has no column named "other".
I thought I could use fixtures as common place to reference in my tests, but doesn't need to match my DB.
Upvotes: 0
Views: 999
Reputation: 1005
Fixtures are your data, they still require a place to go!
"Fixtures allow you to populate your testing database with predefined data before your tests run. Fixtures are database independent written in YAML. There is one file per model."
http://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures
They are not some sort of in memory replacement for a testing database, they just allow you to pre-populate your test database with values, so that you can test more conveniently without having to put lots of data in, when setting up a test run. That's all.
Upvotes: 2