Permalink
Browse files

fix rescue and ensure blocks (close #374)

  • Loading branch information...
1 parent 7d9d7d0 commit e4df090c2c82c3563bcc4e625cbd6ab55a60caf8 @minad minad committed Apr 6, 2013
Showing with 43 additions and 1 deletion.
  1. +1 −1 lib/slim/end_inserter.rb
  2. +42 −0 test/core/test_code_structure.rb
View
@@ -10,7 +10,7 @@ module Slim
#
# @api private
class EndInserter < Filter
- ELSE_REGEX = /\A(else|elsif|when)\b/
+ ELSE_REGEX = /\A(else|elsif|when|rescue|ensure)\b/
END_REGEX = /\Aend\b/
# Handle multi expression `[:multi, *exps]`
@@ -104,4 +104,46 @@ def test_render_with_yield
'This is the menu'
end
end
+
+ def test_render_with_begin_rescue
+ source = %q{
+- begin
+ p Begin
+- rescue
+ p Rescue
+p After
+}
+
+ assert_html '<p>Begin</p><p>After</p>', source
+ end
+
+ def test_render_with_begin_rescue_exception
+ source = %q{
+- begin
+ p Begin
+ - raise 'Boom'
+ p After Boom
+- rescue => ex
+ p = ex.message
+p After
+}
+
+ assert_html '<p>Begin</p><p>Boom</p><p>After</p>', source
+ end
+
+ def test_render_with_begin_rescue_ensure
+ source = %q{
+- begin
+ p Begin
+ - raise 'Boom'
+ p After Boom
+- rescue => ex
+ p = ex.message
+- ensure
+ p Ensure
+p After
+}
+
+ assert_html '<p>Begin</p><p>Boom</p><p>Ensure</p><p>After</p>', source
+ end
end

0 comments on commit e4df090

Please sign in to comment.