2015-10-04 7 views
0

Я использую Rails 4.2.3 с sqlite. У меня есть простой «assert true» unit test, используя встроенный ActiveSupport :: TestCase.Rails 4 создает тестовую базу данных

Существует одна миграция в db/migrate.

Я не знаю, почему следующие причины тесты пройдены успешно, я ожидаю, чтобы получить «отложенную Миграции» ошибка:

rwc $ rake db:drop:all 
rwc $ rake db:migrate:status 
Schema migrations table does not exist yet. 
rwc $ rake db:migrate:status RAILS_ENV=test 
Schema migrations table does not exist yet. 
rwc $ rake test 
Run options: --seed 43484 

# Running: 

. 

Finished in 0.011646s, 85.8671 runs/s, 85.8671 assertions/s. 

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips 

Испытание не взаимодействует с базой данных, до сих пор я ожидал там быть ошибка из-за миграций, которые не были применены.

Может ли кто-нибудь объяснить это поведение?

ответ

0

Буквально только что прочитал следующее:

In order to run your tests, your test database will need to have the current structure. The test helper checks whether your test database has any pending migrations. If so, it will try to load your db/schema.rb or db/structure.sql into the test database. If migrations are still pending, an error will be raised. Usually this indicates that your schema is not fully migrated. Running the migrations against the development database (bin/rake db:migrate) will bring the schema up to date.

Ссылка: http://guides.rubyonrails.org/testing.html#rails-sets-up-for-testing-from-the-word-go

Смежные вопросы