Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed- Machine dependent AR test cases #13527

Merged
merged 1 commit into from

2 participants

@kuldeepaggarwal

This is a follow up to #13469, and #13478
When user tried to execute test cases(either for a particular adapter or for all adapters), like:

$rake test_mysql2

  1) Failure:
MysqlConnectionTest#test_bad_connection [/Volumes/kd/projects/kd-rails/activerecord/test/cases/adapters/mysql2/connection_test.rb:17]:
[ActiveRecord::NoDatabaseError] exception expected, not
Class: <Mysql2::Error>
Message: <"Access denied for user 'root'@'localhost' (using password: NO)">
---Backtrace---
/Users/kd/.rvm/gems/ruby-1.9.3-p448/gems/mysql2-0.3.14/lib/mysql2/client.rb:67:in `connect'
/Users/kd/.rvm/gems/ruby-1.9.3-p448/gems/mysql2-0.3.14/lib/mysql2/client.rb:67:in `initialize'
/Volumes/kd/projects/kd-rails/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/Volumes/kd/projects/kd-rails/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/Volumes/kd/projects/kd-rails/activerecord/test/cases/adapters/mysql2/connection_test.rb:18:in `block in test_bad_connection'
---------------


then all the test cases passed except test_bad_connection test and it is because the user has configured custom password for the adapter. This PR uses ActiveRecord::Base.configurations for executing test_bad_connection test case.

@josevalim josevalim merged commit 1072145 into rails:master

1 check failed

Details default The Travis CI build failed
@kuldeepaggarwal kuldeepaggarwal deleted the kuldeepaggarwal:f-independent-specs branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 29, 2013
  1. @kuldeepaggarwal
This page is out of date. Refresh to see the latest.
View
3  activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
@@ -18,7 +18,8 @@ def setup
def test_bad_connection_mysql
assert_raise ActiveRecord::NoDatabaseError do
- connection = ActiveRecord::Base.mysql_connection(adapter: "mysql", database: "should_not_exist-cinco-dog-db")
+ configuration = ActiveRecord::Base.configurations['arunit'].merge(database: 'should_not_exist-cinco-dog-db')
+ connection = ActiveRecord::Base.mysql_connection(configuration)
connection.exec_query('drop table if exists ex')
end
end
View
3  activerecord/test/cases/adapters/mysql2/connection_test.rb
@@ -15,7 +15,8 @@ def teardown
def test_bad_connection
assert_raise ActiveRecord::NoDatabaseError do
- connection = ActiveRecord::Base.mysql2_connection(adapter: "mysql2", database: "should_not_exist-cinco-dog-db")
+ configuration = ActiveRecord::Base.configurations['arunit'].merge(database: 'should_not_exist-cinco-dog-db')
+ connection = ActiveRecord::Base.mysql2_connection(configuration)
connection.exec_query('drop table if exists ex')
end
end
View
3  activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
@@ -12,7 +12,8 @@ def setup
def test_bad_connection
assert_raise ActiveRecord::NoDatabaseError do
- connection = ActiveRecord::Base.postgresql_connection(database: "should_not_exist-cinco-dog-db", adapter: "postgresql")
+ configuration = ActiveRecord::Base.configurations['arunit'].merge(database: 'should_not_exist-cinco-dog-db')
+ connection = ActiveRecord::Base.postgresql_connection(configuration)
connection.exec_query('drop table if exists ex')
end
end
Something went wrong with that request. Please try again.