-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for running tests against different DB adapters #120
Conversation
364df12
to
adcaa00
Compare
assert_response :redirect | ||
get :index | ||
message = "An error has occurred, this and all later migrations canceled:\n\nActiveRecord::IrreversibleMigration" | ||
message = if ENV["DB_ADAPTER"] == "mysql2" | ||
"An error has occurred, all later migrations canceled:\n\nActiveRecord::IrreversibleMigration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"An error has occurred, all later migrations canceled:\n\nActiveRecord::IrreversibleMigration" | |
"An error has occurred, all subsequent migrations have been canceled:\n\nActiveRecord::IrreversibleMigration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message is generated by Rails and is specific to the database adapter. For MySQL the message is An error has occurred, all subsequent migrations have been canceled
, while for other adapters (PostgreSQL, SQLite) it's An error has occurred, this and all later migrations canceled
. Making the suggested change would cause the test to fail for the MySQL adapter.
message = if ENV["DB_ADAPTER"] == "mysql2" | ||
"An error has occurred, all later migrations canceled:\n\nActiveRecord::IrreversibleMigration" | ||
else | ||
"An error has occurred, this and all later migrations canceled:\n\n" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"An error has occurred, this and all later migrations canceled:\n\n" \ | |
"An error has occurred; this migration and all subsequent ones have been canceled:\n\n" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as here
adcaa00
to
9e64161
Compare
Closes #113
Description
This PR adds new rake tasks to support running tests with different database adapters:
rake test:sqlite3
: Runs tests using SQLite3 (default, equivalent torake test
).rake test:postgresql
: Runs tests using PostgreSQL (requires Docker).rake test:mysql2
: Runs tests using MySQL (requires Docker).rake test:all
: Runs tests across all supported adapters (SQLite3, PostgreSQL, and MySQL). Docker is used for PostgreSQL and MySQL.