mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Fixed an uncought exception when run on the Google App Engine infrastructure.
Signed-off-by: Simon Rozet <simon@rozet.name>
This commit is contained in:
parent
9d67449452
commit
b88c0f579a
2 changed files with 18 additions and 1 deletions
|
@ -635,7 +635,14 @@ module Sinatra
|
|||
# when no file is specified.
|
||||
def use_in_file_templates!(file=nil)
|
||||
file ||= caller_files.first
|
||||
if data = ::IO.read(file).split('__END__')[1]
|
||||
|
||||
begin
|
||||
data = ::IO.read(file).split('__END__')[1]
|
||||
rescue
|
||||
data = nil
|
||||
end
|
||||
|
||||
if data
|
||||
data.gsub!(/\r\n/, "\n")
|
||||
template = nil
|
||||
data.each_line do |line|
|
||||
|
|
|
@ -75,6 +75,16 @@ class TemplatesTest < Test::Unit::TestCase
|
|||
assert_equal "this is foo\n\n", @app.templates[:foo]
|
||||
assert_equal "X\n= yield\nX\n", @app.templates[:layout]
|
||||
end
|
||||
|
||||
test 'use_in_file_templates simply ignores IO errors' do
|
||||
assert_nothing_raised {
|
||||
mock_app {
|
||||
use_in_file_templates!('/foo/bar')
|
||||
}
|
||||
}
|
||||
|
||||
assert @app.templates.empty?
|
||||
end
|
||||
end
|
||||
|
||||
__END__
|
||||
|
|
Loading…
Add table
Reference in a new issue