Skip to content

Commit

Permalink
SafeBuffer#gsub test still failing for $1
Browse files Browse the repository at this point in the history
* ensured the block is passed, refactor test so can't be mislead if block never called
  • Loading branch information
tardate committed Jun 14, 2011
1 parent 21054bd commit 62e2818
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -129,8 +129,8 @@ def #{unsafe_method}!(*args)
#
# If you really need the magic matching variables after the gsub call
# you will need to convert SafeBuffer to a String first
def gsub(*args)
to_str.gsub(*args)
def gsub(*args, &block)
to_str.gsub(*args, &block)
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion activesupport/test/safe_buffer_test.rb
Expand Up @@ -54,7 +54,9 @@ def setup
test "Should set magic match variables within block passed to gsub" do
'burn'[/(matches)/]
@buffer << 'swan'
@buffer.gsub(/(swan)/) { assert_equal 'swan', $1 }
result = nil
@buffer.gsub(/(swan)/) { result = $1 }
assert_equal 'swan', result, "dang it, still not working"
end

test "Should not expect magic match variables after gsub call" do
Expand Down

0 comments on commit 62e2818

Please sign in to comment.