undefined method errors in test specs! but works fine in ./script/console???
Had an issue trying to resolve the following error I was getting in one of my test specs (i.e. RSpec tests) recently:
undefined method `account_item_id=' for #
When I did the same thing the test spec was doing in the rails console (i.e. ./script/console) things worked fine. Couldn’t work it out.
Solution: You may have guessed it. The tests work on the “test” database, not the “development” database. I needed to run the “rake db:migrate RAILS_ENV=test” to bring my test database schema up to date. Doh!
