Skip to content
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

Relax assertions in connection config tests #32674

Merged
merged 1 commit into from Apr 21, 2018

Conversation

composerinteralia
Copy link
Member

At the moment these two ActiveRecord tests pass with rake test:sqlite3,
but fail with ARCONN=sqlite3 bin/test.

Rails.root is defined when running bin/test, but not when running
the rake task. When Rails.root is defined, config[:database] will
look something like vagrant/rails/activerecord/db/primary.sqlite3
instead of just db/primary.sqlite3.

config[:database] = File.expand_path(config[:database], Rails.root) if defined?(Rails.root)

Relaxing assert_equal to assert_match will allow these tests to pass
regardless of how they are run.

I do have a question why we need both ways to run tests. I have been
using bin/test lately, but I see from #32426 that this is not the preferred
method.

At the moment these two ActiveRecord tests pass with `rake test:sqlite3`,
but fail with `ARCONN=sqlite3 bin/test`.

`Rails.root` is defined when running `bin/test`, but not when running
the rake task. When `Rails.root` is defined, `config[:database]` will
look something like `vagrant/rails/activerecord/db/primary.sqlite3`
instead of just `db/primary.sqlite3`.
(See https://github.com/rails/rails/blob/00caf95e14b90782ab17fbd6d2b930844df99980/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L27)

Relaxing `assert_equal` to `assert_match` will allow these tests to pass
regardless of how they are run.

I do have a question why we need both ways to run tests. I have been
using `bin/test` lately, but I see from rails#32426 that this is not the preferred
method.
@rails-bot
Copy link

r? @georgeclaghorn

(@rails-bot has picked a reviewer for you, use r? to override)

@kamipo kamipo merged commit eb2f2fc into rails:master Apr 21, 2018
@kamipo
Copy link
Member

kamipo commented Apr 21, 2018

According to #20480, it is for using the minitest plugin. But probably there are still some problems remaining and nobody is working on it.

@composerinteralia composerinteralia deleted the relax-assertion branch November 24, 2018 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants