Skip to content

Commit 7f6ac9b

Browse files
emirikolbyroot
authored andcommitted
Fix capture view helper to pass keyword arguments
1 parent 7a031e3 commit 7f6ac9b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

actionview/lib/action_view/helpers/capture_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ module CaptureHelper
4444
#
4545
# @greeting # => "Welcome to my shiny new web page! The date and time is 2018-09-06 11:09:16 -0500"
4646
#
47-
def capture(*args, &block)
47+
def capture(*, **, &block)
4848
value = nil
4949
@output_buffer ||= ActionView::OutputBuffer.new
50-
buffer = @output_buffer.capture { value = yield(*args) }
50+
buffer = @output_buffer.capture { value = yield(*, **) }
5151

5252
string = if @output_buffer.equal?(value)
5353
buffer

actionview/test/template/capture_helper_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ def test_capture_captures_the_value_returned_by_the_block_if_the_temporary_buffe
2626
assert_equal "foobar", string
2727
end
2828

29+
def test_capture_with_keyword_arguments
30+
string = @av.capture("foo", b: "bar") do |a, b:|
31+
a + b
32+
end
33+
assert_equal "foobar", string
34+
end
35+
2936
def test_capture_returns_nil_if_the_returned_value_is_not_a_string
3037
assert_nil @av.capture { 1 }
3138
end

0 commit comments

Comments
 (0)