diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-10 10:23:17 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-10 10:23:17 -0300 |
commit | d547b2375465ec1a669f01386e988d32845eaa4c (patch) | |
tree | de240aada7cb0fc5701f4c4045970e8a7f4aaaac /activerecord | |
parent | 18b9595814057095084f508b6837ad3c7331079f (diff) | |
download | rails-d547b2375465ec1a669f01386e988d32845eaa4c.tar.gz rails-d547b2375465ec1a669f01386e988d32845eaa4c.tar.bz2 rails-d547b2375465ec1a669f01386e988d32845eaa4c.zip |
Change the assertions depending in the database adapter
This will avoid the confusing flunk logic
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 0ab3830323..0da2fe41c5 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -62,22 +62,17 @@ class FinderTest < ActiveRecord::TestCase end def test_exists_fails_when_parameter_has_invalid_type - begin - assert_equal false, Topic.exists?(("9"*53).to_i) # number that's bigger than int - flunk if current_adapter?(:PostgreSQLAdapter) # PostgreSQL does raise here - rescue ActiveRecord::StatementInvalid - # PostgreSQL complains that it can't coerce a numeric that's bigger than int into int - rescue Exception - flunk - end + if current_adapter?(:PostgreSQLAdapter) + assert_raises ActiveRecord::StatementInvalid do + Topic.exists?(("9"*53).to_i) # number that's bigger than int + end - begin + assert_raises ActiveRecord::StatementInvalid do + Topic.exists?("foo") + end + else + assert_equal false, Topic.exists?(("9"*53).to_i) # number that's bigger than int assert_equal false, Topic.exists?("foo") - flunk if current_adapter?(:PostgreSQLAdapter) # PostgreSQL does raise here - rescue ActiveRecord::StatementInvalid - # PostgreSQL complains about string comparison with integer field - rescue Exception - flunk end end |