test/stripe/stripe_object_test.rb in stripe-1.29.1 vs test/stripe/stripe_object_test.rb in stripe-1.30.0

- old
+ new

@@ -9,10 +9,21 @@ assert obj1 == obj2 refute obj1 == obj3 end + should "implement #deleted?" do + obj = Stripe::StripeObject.construct_from({}) + refute obj.deleted? + + obj = Stripe::StripeObject.construct_from({ :deleted => false }) + refute obj.deleted? + + obj = Stripe::StripeObject.construct_from({ :deleted => true }) + assert obj.deleted? + end + should "implement #respond_to" do obj = Stripe::StripeObject.construct_from({ :id => 1, :foo => 'bar' }) assert obj.respond_to?(:id) assert obj.respond_to?(:foo) assert !obj.respond_to?(:baz) @@ -51,12 +62,27 @@ should "mass assign values with #update_attributes" do obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' }) obj.update_attributes(:name => 'STRIPE') assert_equal "STRIPE", obj.name - e = assert_raises(ArgumentError) do - obj.update_attributes(:foo => 'bar') + # unfortunately, we even assign unknown properties to duplicate the + # behavior that we currently have via magic accessors with + # method_missing + obj.update_attributes(:unknown => 'foo') + assert_equal "foo", obj.unknown + end + + should "warn that #refresh_from is deprecated" do + old_stderr = $stderr + $stderr = StringIO.new + begin + obj = Stripe::StripeObject.construct_from({}) + obj.refresh_from({}, {}) + message = "NOTE: Stripe::StripeObject#refresh_from is " + + "deprecated; use #update_attributes instead" + assert_match Regexp.new(message), $stderr.string + ensure + $stderr = old_stderr end - assert_equal "foo is not an attribute that can be assigned on this object", e.message end end end