Tests for specifying path/line added

This commit is contained in:
George 2013-10-21 16:43:53 +04:00 committed by Zachary Scott
parent 2330449a0d
commit 73c182cfb1
1 changed files with 22 additions and 0 deletions

View File

@ -100,6 +100,28 @@ class TemplatesTest < Minitest::Test
assert_equal 'Hello World', body
end
it 'allows to specify path/line when rendering with String' do
path = 'example.txt'
line = 228
begin render_app {
render :erb, '<%= doesnotexist %>', {:path => path, :line => line}
}
rescue NameError => e
assert_match(/#{path}:#{line}/, e.backtrace.first)
end
end
it 'allows to specify path/line when rendering with Proc' do
path = 'example.txt'
line = 900
begin render_app {
render :erb, Proc.new { '<%= doesnotexist %>' }, {:path => path, :line => line}
}
rescue NameError => e
assert_match(/#{path}:#{line}/, e.backtrace.first)
end
end
it 'renders Proc templates using the call result' do
render_app { render(:test, Proc.new {'Hello World'}) }
assert ok?