Permalink
Browse files

Block helper returns itself (the renderer object)

  • Loading branch information...
1 parent 1813273 commit 7a00bbfa2195a7d5dda4d9c1d0b3e8e3ba220d93 Mark Evans committed Aug 26, 2009
Showing with 15 additions and 1 deletion.
  1. +2 −1 lib/block_helpers.rb
  2. +13 −0 spec/helpers/block_helpers_spec.rb
View
3 lib/block_helpers.rb
@@ -26,8 +26,9 @@ def #{method_name}(*args, &block)
concat renderer.display(body), binding
end
else
- block.call(renderer)
+ block.call(renderer) if block
end
+ renderer
end
)
end
View
13 spec/helpers/block_helpers_spec.rb
@@ -32,6 +32,19 @@ def hello
)).should match_html("<p>Before</p> Hi there <p>After</p>")
end
+ it "should do nothing if no block given" do
+ eval_erb(%(
+ <% test_helper %>
+ )).should match_html("")
+ end
+
+ it "should return itself (the renderer object)" do
+ eval_erb(%(
+ <% e = test_helper %>
+ <%= e.hello %>
+ )).should match_html('Hi there')
+ end
+
end
describe "access to other methods" do

0 comments on commit 7a00bbf

Please sign in to comment.