Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Block helper returns itself (the renderer object)

  • Loading branch information...
commit 7a00bbfa2195a7d5dda4d9c1d0b3e8e3ba220d93 1 parent 1813273
@markevans authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.