diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-21 17:20:51 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-21 17:20:51 +0000 |
commit | 39814fcce0b429eb06654600e4669f1405ffa7d9 (patch) | |
tree | bc5cbe7888b3c31b1e2a92f246512218014fdf76 /activerecord/lib/active_record | |
parent | 1d4f4cdfe22cbe4962ae8953c96bc5c70d8d4e6a (diff) | |
download | rails-39814fcce0b429eb06654600e4669f1405ffa7d9.tar.gz rails-39814fcce0b429eb06654600e4669f1405ffa7d9.tar.bz2 rails-39814fcce0b429eb06654600e4669f1405ffa7d9.zip |
Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/test_case.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb new file mode 100644 index 0000000000..d5126849be --- /dev/null +++ b/activerecord/lib/active_record/test_case.rb @@ -0,0 +1,35 @@ +require "active_support/test_case" + +module ActiveRecord + class TestCase < ActiveSupport::TestCase #:nodoc: + self.fixture_path = FIXTURES_ROOT + self.use_instantiated_fixtures = false + + def create_fixtures(*table_names, &block) + Fixtures.create_fixtures(FIXTURES_ROOT, table_names, {}, &block) + end + + def assert_date_from_db(expected, actual, message = nil) + # SQL Server doesn't have a separate column type just for dates, + # so the time is in the string and incorrectly formatted + if current_adapter?(:SQLServerAdapter) + assert_equal expected.strftime("%Y/%m/%d 00:00:00"), actual.strftime("%Y/%m/%d 00:00:00") + elsif current_adapter?(:SybaseAdapter) + assert_equal expected.to_s, actual.to_date.to_s, message + else + assert_equal expected.to_s, actual.to_s, message + end + end + + def assert_queries(num = 1) + $query_count = 0 + yield + ensure + assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed." + end + + def assert_no_queries(&block) + assert_queries(0, &block) + end + end +end |