aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/template_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/template/template_test.rb')
-rw-r--r--actionpack/test/template/template_test.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb
index fbc9350c69..c7c33af670 100644
--- a/actionpack/test/template/template_test.rb
+++ b/actionpack/test/template/template_test.rb
@@ -6,6 +6,7 @@ class TestERBTemplate < ActiveSupport::TestCase
class Context
def initialize
@output_buffer = "original"
+ @_virtual_path = nil
end
def hello
@@ -82,12 +83,11 @@ class TestERBTemplate < ActiveSupport::TestCase
# is set to something other than UTF-8, we don't
# get any errors and get back a UTF-8 String.
def test_default_external_works
- Encoding.default_external = "ISO-8859-1"
- @template = new_template("hello \xFCmlat")
- assert_equal Encoding::UTF_8, render.encoding
- assert_equal "hello \u{fc}mlat", render
- ensure
- Encoding.default_external = "UTF-8"
+ with_external_encoding "ISO-8859-1" do
+ @template = new_template("hello \xFCmlat")
+ assert_equal Encoding::UTF_8, render.encoding
+ assert_equal "hello \u{fc}mlat", render
+ end
end
def test_encoding_can_be_specified_with_magic_comment
@@ -123,10 +123,11 @@ class TestERBTemplate < ActiveSupport::TestCase
end
def with_external_encoding(encoding)
- old, Encoding.default_external = Encoding.default_external, encoding
+ old = Encoding.default_external
+ silence_warnings { Encoding.default_external = encoding }
yield
ensure
- Encoding.default_external = old
+ silence_warnings { Encoding.default_external = old }
end
end
end