vendredi 25 septembre 2015

Minitest doesn't respect setting config.active_record.pluralize_table_names to false

I've been trying to set up my first tests on Rails 4.2.4 but usually I use singularized table names in DBs, thus I add this line into config/application.rb

config.active_record.pluralize_table_names = false

Since I've being working on Car and User models, let's assume I've already generated each scaffold, and already executed rake db:test:prepare so the problem begins with tests as follows:

In test/models/car_test.rb or user_test.rb, first I uncomment stub test "the truth" and run vanilla with the following error with rake test:models

# Running:

EE

Finished in 0.019095s, 104.7396 runs/s, 0.0000 assertions/s.

  1) Error:
UserTest#test_the_truth:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: users: DELETE FROM "users"



  2) Error:
CarTest#test_necessary_car_data:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: users: DELETE FROM "users"


2 runs, 0 assertions, 0 failures, 2 errors, 0 skips

When I run rake test:controllers the same ActiveRecord error shows up multiple times and I cannot fix this behaviour in any way so far.

Somebody else has come across with this issue? It's driving me mad...

PS: All development does well without any issues with singular table names, the only mess lies in testing.

Aucun commentaire:

Enregistrer un commentaire