in an app I work on test suite is done with Minitest and fixtures and I faced such a problem, I can't solve, neither find a solution.
I have a model Survey
and fixtures for it test/fixtures/surveys.yml
:
one:
user: admin
name: Survey one
description: This is survey one
company: university
review_type: 1
two:
user: admin
name: Survey two
description: This is survey two
company: university
also, I have namespace surveys
and there a model for question - Surveys::Question
(with polymorphic association), which has corresponding fixtures test/fixtures/surveys/questions.yml
:
one:
sentence: Survey question one?
display_order: 1
question_type: 0
questionable: one (Survey)
two:
sentence: Survey question two?
display_order: 2
question_type: 1
questionable: one (Survey)
So far so good, things work. But whenever I try to add another questions
definition to fixtures, let's say:
three:
sentence: Survey question three?
display_order: 3
question_type: 2
questionable: one (Survey)
an error is raised: ActiveRecord::Fixture::FixtureError: table "surveys" has no column named "sentence"
I totally can't follow up, why suddenly ActiveRecord::Fixtures
fails to follow up.
I would be grateful for any suggestion on this.
Make sure your database schema has not changed and that you didn't remove or rename the column or table in your database. Whenever you change your schema and run your migrations, be sure to run this before running your tests:
rake db:test:prepare
Then try running your tests again. If you get the same error, it indicates your test database is missing that column. Check your migrations to make sure.
Also, do you think maybe you need three:
in test/fixtures/surveys.yml
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With