Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SafeBuffer#gsub test still failing for $1

* ensured the block is passed, refactor test so can't be mislead if block never called
  • Loading branch information...
commit 62e2818c44cc38240de457236f76830936b2c42d 1 parent 21054bd
@tardate authored
View
4 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -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
View
4 activesupport/test/safe_buffer_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.