diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-06-26 13:34:50 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-26 22:37:45 +0200 |
commit | 100d2282e306f68d8ce0324128da1506eafc43a2 (patch) | |
tree | 9685879e9c4e7100a5fb14d61b374db1dd3f3716 /activerecord/test/cases | |
parent | 5b91c97763f1183f131e46e51ed33129c6b1edcc (diff) | |
download | rails-100d2282e306f68d8ce0324128da1506eafc43a2.tar.gz rails-100d2282e306f68d8ce0324128da1506eafc43a2.tar.bz2 rails-100d2282e306f68d8ce0324128da1506eafc43a2.zip |
adding adapter tests, avoiding private apis, fixing code in 1.9 [#4986 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/sqlite/sqlite3_adapter_test.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/sqlite/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite/sqlite3_adapter_test.rb new file mode 100644 index 0000000000..934cf72f72 --- /dev/null +++ b/activerecord/test/cases/adapters/sqlite/sqlite3_adapter_test.rb @@ -0,0 +1,56 @@ +require "cases/helper" + +module ActiveRecord + module ConnectionAdapters + class SQLite3AdapterTest < ActiveRecord::TestCase + def test_connection_no_db + assert_raises(ArgumentError) do + Base.sqlite3_connection {} + end + end + + def test_connection_no_adapter + assert_raises(ArgumentError) do + Base.sqlite3_connection :database => ':memory:' + end + end + + def test_connection_wrong_adapter + assert_raises(ArgumentError) do + Base.sqlite3_connection :database => ':memory:',:adapter => 'vuvuzela' + end + end + + def test_bad_timeout + assert_raises(TypeError) do + Base.sqlite3_connection :database => ':memory:', + :adapter => 'sqlite3', + :timeout => 'usa' + end + end + + # connection is OK with a nil timeout + def test_nil_timeout + conn = Base.sqlite3_connection :database => ':memory:', + :adapter => 'sqlite3', + :timeout => nil + assert conn, 'made a connection' + end + + def test_connect + conn = Base.sqlite3_connection :database => ':memory:', + :adapter => 'sqlite3', + :timeout => 100 + assert conn, 'should have connection' + end + + # sqlite3 defaults to UTF-8 encoding + def test_encoding + conn = Base.sqlite3_connection :database => ':memory:', + :adapter => 'sqlite3', + :timeout => 100 + assert_equal 'UTF-8', conn.encoding + end + end + end +end |