Permalink
Browse files

DRY with_kcode in Active Record tests

  • Loading branch information...
1 parent dfcf1e4 commit fd3ccbe955ed58298df43f537a01358d15d8d4cf @lifo lifo committed Mar 7, 2009
@@ -49,5 +49,18 @@ def connection_allow_concurrency_teardown
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
@@ -2099,18 +2099,4 @@ def test_create_with_custom_timestamps
assert_equal custom_datetime, parrot[attribute]
end
end
-
- private
- 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
@@ -1442,20 +1442,6 @@ def test_validation_with_if_as_string
t.author_name = "Hubert J. Farnsworth"
assert t.valid?, "A topic with an important title and author should be valid"
end
-
- private
- 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

0 comments on commit fd3ccbe

Please sign in to comment.