test/stripe/source_test.rb in stripe-3.0.3 vs test/stripe/source_test.rb in stripe-3.1.0

- old
+ new

@@ -1,53 +1,54 @@ require File.expand_path('../../test_helper', __FILE__) module Stripe class SourceTest < Test::Unit::TestCase - FIXTURE = API_FIXTURES.fetch(:source) - should "be retrievable" do - source = Stripe::Source.retrieve(FIXTURE[:id]) - assert_requested :get, "#{Stripe.api_base}/v1/sources/#{FIXTURE[:id]}" + source = Stripe::Source.retrieve("src_123") + assert_requested :get, "#{Stripe.api_base}/v1/sources/src_123" assert source.kind_of?(Stripe::Source) end should "be creatable" do source = Stripe::Source.create( type: 'card', - token: API_FIXTURES.fetch(:token)[:id] + token: "tok_123" ) assert_requested :post, "#{Stripe.api_base}/v1/sources" assert source.kind_of?(Stripe::Source) end should "be saveable" do - source = Stripe::Source.retrieve(FIXTURE[:id]) + source = Stripe::Source.retrieve("src_123") source.metadata['key'] = 'value' source.save - assert_requested :post, "#{Stripe.api_base}/v1/sources/#{FIXTURE[:id]}" + assert_requested :post, "#{Stripe.api_base}/v1/sources/#{source.id}" end should "be updateable" do - source = Stripe::Source.update(FIXTURE[:id], metadata: {foo: 'bar'}) - assert_requested :post, "#{Stripe.api_base}/v1/sources/#{FIXTURE[:id]}" + source = Stripe::Source.update("src_123", metadata: {foo: 'bar'}) + assert_requested :post, "#{Stripe.api_base}/v1/sources/src_123" assert source.kind_of?(Stripe::Source) end context "#delete" do should "not be deletable when unattached" do - source = Stripe::Source.retrieve(FIXTURE[:id]) + source = Stripe::Source.retrieve("src_123") assert_raises NotImplementedError do source.delete end end should "be deletable when attached to a customer" do - customer_id = API_FIXTURES.fetch(:customer)[:id] - source = Stripe::Source.construct_from(FIXTURE.merge(customer: customer_id)) - stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer_id}/sources/#{FIXTURE[:id]}"). - to_return(body: JSON.generate(FIXTURE)) + source = Stripe::Source.construct_from({ + customer: "cus_123", + id: "src_123", + object: "source" + }) + source = source.delete + assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123/sources/src_123" assert source.kind_of?(Stripe::Source) end end should 'not be listable' do @@ -56,10 +57,10 @@ end end context "#verify" do should "verify the source" do - source = Stripe::Source.retrieve(FIXTURE[:id]) + source = Stripe::Source.retrieve("src_123") source = source.verify(:values => [1,2]) assert source.kind_of?(Stripe::Source) end end end