Skip to content

Commit

Permalink
fix rescue and ensure blocks (close #374)
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Apr 6, 2013
1 parent 7d9d7d0 commit e4df090
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/slim/end_inserter.rb
Expand Up @@ -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]`
Expand Down
42 changes: 42 additions & 0 deletions test/core/test_code_structure.rb
Expand Up @@ -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.