diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-03-07 11:06:39 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-07 11:06:44 +0000 |
commit | fd3ccbe955ed58298df43f537a01358d15d8d4cf (patch) | |
tree | 8c408cc956781aaaae09290f78db2288794d9e2c /activerecord/lib | |
parent | dfcf1e4cf6128ae67f9cab291fd6c08081aa5d80 (diff) | |
download | rails-fd3ccbe955ed58298df43f537a01358d15d8d4cf.tar.gz rails-fd3ccbe955ed58298df43f537a01358d15d8d4cf.tar.bz2 rails-fd3ccbe955ed58298df43f537a01358d15d8d4cf.zip |
DRY with_kcode in Active Record tests
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/test_case.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb index 211dd78874..8c6abaaccb 100644 --- a/activerecord/lib/active_record/test_case.rb +++ b/activerecord/lib/active_record/test_case.rb @@ -49,5 +49,18 @@ module ActiveRecord ActiveRecord::Base.clear_all_connections! ActiveRecord::Base.establish_connection(@connection) end + + def with_kcode(kcode) + if RUBY_VERSION < '1.9' + orig_kcode, $KCODE = $KCODE, kcode + begin + yield + ensure + $KCODE = orig_kcode + end + else + yield + end + end end end |