this should have gone with the previous commit

This commit is contained in:
Xavier Noria 2011-09-08 05:02:47 -07:00
parent f7627de206
commit 827fcf453e
2 changed files with 6 additions and 6 deletions

View File

@ -158,17 +158,17 @@ module ActiveSupport #:nodoc:
UNAVAILABLE_STRING_METHODS.each do |unavailable_method|
class_eval <<-EOT, __FILE__, __LINE__
# def gsub(*args)
# raise NoMethodError, "gsub cannot be used with a safe string. You should use object.to_str.gsub."
# raise NoMethodError, "gsub cannot be used with a safe string. You should use object.to_str.gsub"
# end
def #{unavailable_method}(*args)
raise NoMethodError, "#{unavailable_method} cannot be used with a safe string. You should use object.to_str.#{unavailable_method}."
raise NoMethodError, "#{unavailable_method} cannot be used with a safe string. You should use object.to_str.#{unavailable_method}"
end
# def gsub!(*args)
# raise NoMethodError, "gsub! cannot be used with a safe string. You should use object.to_str.gsub!."
# raise NoMethodError, "gsub! cannot be used with a safe string. You should use object.to_str.gsub!"
# end
def #{unavailable_method}!(*args)
raise NoMethodError, "#{unavailable_method}! cannot be used with a safe string. You should use object.to_str.#{unavailable_method}!."
raise NoMethodError, "#{unavailable_method}! cannot be used with a safe string. You should use object.to_str.#{unavailable_method}!"
end
EOT
end

View File

@ -114,13 +114,13 @@ class SafeBufferTest < ActiveSupport::TestCase
["gsub", "sub"].each do |unavailable_method|
test "should raise on #{unavailable_method}" do
assert_raise NoMethodError, "#{unavailable_method} cannot be used with a Safe Buffer object. You should use object.to_str.#{unavailable_method}" do
assert_raise NoMethodError, "#{unavailable_method} cannot be used with a safe string. You should use object.to_str.#{unavailable_method}" do
@buffer.send(unavailable_method, '', '<>')
end
end
test "should raise on #{unavailable_method}!" do
assert_raise NoMethodError, "#{unavailable_method}! cannot be used with a Safe Buffer object. You should use object.to_str.#{unavailable_method}!" do
assert_raise NoMethodError, "#{unavailable_method}! cannot be used with a safe string. You should use object.to_str.#{unavailable_method}!" do
@buffer.send("#{unavailable_method}!", '', '<>')
end
end