test/test_rhubarb.rb in rhubarb-0.2.4 vs test/test_rhubarb.rb in rhubarb-0.2.5

- old
+ new

@@ -10,10 +10,11 @@ # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 require 'helper' +require 'fileutils' class TestClass include Rhubarb::Persisting declare_column :foo, :integer declare_column :bar, :string @@ -90,13 +91,25 @@ class BlobTestTable include Rhubarb::Persisting declare_column :info, :blob end -class BackendBasicTests < Test::Unit::TestCase +class PreparedStmtBackendTests < Test::Unit::TestCase + def dbfile + ENV['RHUBARB_TEST_DB'] || ":memory:" + end + + def use_prepared + true + end + def setup - Rhubarb::Persistence::open(":memory:") + unless dbfile == ":memory:" + FileUtils::safe_unlink(dbfile) + end + + Rhubarb::Persistence::open(dbfile, :default, use_prepared) klasses = [] klasses << TestClass klasses << TestClass2 klasses << TC3 klasses << TC4 @@ -214,10 +227,17 @@ assert(bogus_include == false, "#{m} method declared in TestClass; shouldn't be") end end end + def test_delete_all + freshness_query_fixture + assert(FreshTestTable.find_all.size > 0) + FreshTestTable.delete_all + assert_equal([], FreshTestTable.find_all) + end + def test_class_methods ["foo", "bar"].each do |prefix| ["find_by_#{prefix}", "find_first_by_#{prefix}"].each do |m| klass = class << TestClass; self end assert klass.instance_methods.include?(m), "#{m} method not declared in TestClass' eigenclass" @@ -708,6 +728,12 @@ assert_equal(text, btrow.info) assert_equal(text, Zlib::Inflate.inflate(cbtrow.info)) end +end + +class NoPreparedStmtBackendTests < PreparedStmtBackendTests + def use_prepared + false + end end