RSpec Missing New Table

Gani

Gani / January 25, 2019

This was after I rolled back the last migration that creates the `Comment` model, added a `is_public` boolean attribute to it, then rerunning the migration.

Then I started working on the controller for the commenting feature. Doing TDD while implementing the updates on the controller when I noticed my tests fail while the controller seems to work as expected when doing the workflow on the browser.

In the development database the boolean attribute is reflecting but not in the tests.

Comments model that RSpec is using does not have the `is_public` boolean attribute.
RSpec Logs

I thought this was because of the way I setup FactoryBot class for the comment model. Also blamed the boolean attribute issue with RSpec.
Me thinking

After a lot of trials and fails and research I bumped into this:
https://stackoverflow.com/questions/5264355/rspec-failure-could-not-find-table-after-migration

It suggests that the test database is not using same schema as the development db.

Followed the voted answer on the SO page and it fixed the problem. 

Here are the scripts I ran in the terminal.
rake db:test:prepare
rake db:migrate spec

See the log now show the `is_public` attribute.
 
RSpec Logs

I have not experienced this in Linux, just now that I am on a Mac.

Posting this just maybe someone could experience the same problem.