mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-01 00:00:30 -04:00
Merge pull request #404 from stripe/brandur-improve-error-message
Improve error message on setting empty strings
This commit is contained in:
commit
9ae8a49697
@ -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])
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user