Permalink
Browse files

Fix for SafeBuffer#gsub and magic match globs

* to_str in preference of String.new
* tests + metaphorical exactitude
  • Loading branch information...
1 parent 5107f39 commit 1fa11344c5ba8f59d527c747f381ec69a77c8a1c @tardate committed Jun 10, 2011
@@ -130,7 +130,7 @@ def #{unsafe_method}!(*args)
# If you really need the magic matching variables after the gsub call
# you will need to covert SafeBuffer to a String first
def gsub(*args)
- String.new(self).gsub(*args)
+ to_str.gsub(*args)
end
end
end
@@ -52,13 +52,13 @@ def setup
end
test "Should set magic match variables within block passed to gsub" do
- 'clear'[/(matches)/]
+ 'burn'[/(matches)/]
@buffer << 'swan'
@buffer.gsub(/(swan)/) { assert_equal 'swan', $1 }
end
test "Should not expect magic match variables after gsub call" do
- 'clear'[/(matches)/]
+ 'burn'[/(matches)/]
@buffer << 'vesta'
@buffer.gsub(/(vesta)/, '')
assert !$1, %(

0 comments on commit 1fa1134

Please sign in to comment.