test/unit/ardb_tests.rb in ardb-0.28.2 vs test/unit/ardb_tests.rb in ardb-0.28.3
- old
+ new
@@ -12,14 +12,17 @@
class UnitTests < Assert::Context
desc "Ardb"
setup do
@module = Ardb
end
+ teardown do
+ @module.reset_adapter
+ end
subject{ @module }
- should have_imeths :config, :configure, :adapter, :init
- should have_imeths :escape_like_pattern
+ should have_imeths :config, :configure, :adapter, :reset_adapter
+ should have_imeths :init, :escape_like_pattern
should "default the db file env var" do
assert_equal 'config/db', ENV['ARDB_DB_FILE']
end
@@ -118,9 +121,19 @@
subject.init(true)
assert_equal 2, @ardb_adapter.connect_db_called_count
subject.init(false)
assert_equal 2, @ardb_adapter.connect_db_called_count
+ end
+
+ should "raise a not initialized error using its adapter before init" do
+ subject.reset_adapter
+ assert_raises(NotInitializedError){ subject.adapter }
+ assert_raises(NotInitializedError){ subject.escape_like_pattern(Factory.string) }
+
+ subject.init
+ assert_nothing_raised{ subject.adapter }
+ assert_nothing_raised{ subject.escape_like_pattern(Factory.string) }
end
end
class InitTests < InitMethodSetupTests