Permalink
Browse files

Fixed an uncought exception when run on the Google App Engine infrast…

…ructure.

Signed-off-by: Simon Rozet <simon@rozet.name>
  • Loading branch information...
1 parent 9d67449 commit b88c0f579aabf4d32e8b6c2e3d861506e0f9a8f1 Samuel Goebert committed with rtomayko Apr 9, 2009
Showing with 18 additions and 1 deletion.
  1. +8 −1 lib/sinatra/base.rb
  2. +10 −0 test/templates_test.rb
View
@@ -635,7 +635,14 @@ def layout(name=:layout, &block)
# 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|
View
@@ -75,6 +75,16 @@ def with_default_layout
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__

0 comments on commit b88c0f5

Please sign in to comment.