class LazyViewRenderTest
Public Instance Methods
setup()
click to toggle source
Test the same thing as above, but make sure the view path is not eager loaded
# File actionview/test/template/render_test.rb, line 619 def setup path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) view_paths = ActionView::PathSet.new([path]) assert_equal ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH), view_paths.first setup_view(view_paths) end
teardown()
click to toggle source
# File actionview/test/template/render_test.rb, line 626 def teardown GC.start I18n.reload! end
test_render_utf8_template_with_default_external_encoding()
click to toggle source
# File actionview/test/template/render_test.rb, line 639 def test_render_utf8_template_with_default_external_encoding with_external_encoding Encoding::UTF_8 do result = @view.render(file: "test/utf8", formats: [:html], layouts: "layouts/yield") assert_equal Encoding::UTF_8, result.encoding assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result end end
test_render_utf8_template_with_incompatible_external_encoding()
click to toggle source
# File actionview/test/template/render_test.rb, line 647 def test_render_utf8_template_with_incompatible_external_encoding with_external_encoding Encoding::SHIFT_JIS do e = assert_raises(ActionView::Template::Error) { @view.render(file: "test/utf8", formats: [:html], layouts: "layouts/yield") } assert_match "Your template was not saved as valid Shift_JIS", e.cause.message end end
test_render_utf8_template_with_magic_comment()
click to toggle source
# File actionview/test/template/render_test.rb, line 631 def test_render_utf8_template_with_magic_comment with_external_encoding Encoding::ASCII_8BIT do result = @view.render(file: "test/utf8_magic", formats: [:html], layouts: "layouts/yield") assert_equal Encoding::UTF_8, result.encoding assert_equal "\nРусский \nтекст\n\nUTF-8\nUTF-8\nUTF-8\n", result end end
test_render_utf8_template_with_partial_with_incompatible_encoding()
click to toggle source
# File actionview/test/template/render_test.rb, line 654 def test_render_utf8_template_with_partial_with_incompatible_encoding with_external_encoding Encoding::SHIFT_JIS do e = assert_raises(ActionView::Template::Error) { @view.render(file: "test/utf8_magic_with_bare_partial", formats: [:html], layouts: "layouts/yield") } assert_match "Your template was not saved as valid Shift_JIS", e.cause.message end end
with_external_encoding(encoding) { || ... }
click to toggle source
# File actionview/test/template/render_test.rb, line 661 def with_external_encoding(encoding) old = Encoding.default_external silence_warnings { Encoding.default_external = encoding } yield ensure silence_warnings { Encoding.default_external = old } end