Merge pull request #404 from stripe/brandur-improve-error-message

Improve error message on setting empty strings
This commit is contained in:
Brandur 2016-03-28 08:09:21 -07:00
commit 9ae8a49697
2 changed files with 9 additions and 1 deletions

View File

@ -233,7 +233,7 @@ module Stripe
raise ArgumentError.new(
"You cannot set #{k} to an empty string. " \
"We interpret empty strings as nil in requests. " \
"You may set #{self}.#{k} = nil to delete the property.")
"You may set (object).#{k} = nil to delete the property.")
end
@values[k] = Util.convert_to_stripe_object(v, @opts)
dirty_value!(@values[k])

View File

@ -286,5 +286,13 @@ module Stripe
$stderr = old_stderr
end
end
should "error on setting a property to an empty string" do
obj = Stripe::StripeObject.construct_from({ :foo => 'bar' })
e = assert_raises ArgumentError do
obj.foo = ""
end
assert_match /\(object\).foo = nil/, e.message
end
end
end