Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michelle authored and michelle-stripe committed Jan 7, 2014
1 parent 82c7254 commit 035cc65
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
19 changes: 19 additions & 0 deletions test/remote/gateways/remote_stripe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,25 @@ def test_successful_store
assert_equal @credit_card.last_digits, first_card["last4"]
end

def test_successful_store_with_existing_customer
assert response = @gateway.store(@credit_card, {:currency => @currency, :description => "Active Merchant Test Customer"})
assert_success response

assert response = @gateway.store(@new_credit_card, {:customer => response.params['id'], :currency => @currency, :description => "Active Merchant Test Customer", :email => "[email protected]"})
assert_success response
assert_equal 2, response.responses.size

card_response = response.responses[0]
assert_equal "card", card_response.params["object"]
assert_equal @new_credit_card.last_digits, card_response.params["last4"]

customer_response = response.responses[1]
assert_equal "customer", customer_response.params["object"]
assert_equal "Active Merchant Test Customer", customer_response.params["description"]
assert_equal "[email protected]", customer_response.params["email"]
assert_equal 2, customer_response.params["cards"]["count"]
end

def test_successful_update
creation = @gateway.store(@credit_card, {:description => "Active Merchant Update Customer"})
assert response = @gateway.update(creation.params['id'], @new_credit_card)
Expand Down
16 changes: 15 additions & 1 deletion test/unit/gateways/stripe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,28 @@ def test_successful_new_customer_with_card
def test_successful_new_card
@gateway.expects(:ssl_request).returns(successful_new_card_response)

assert response = @gateway.store(@credit_card, @options.merge(:customer => 'cus_3sgheFxeBgTQ3M'))
assert response = @gateway.store(@credit_card, :customer => 'cus_3sgheFxeBgTQ3M')
assert_instance_of MultiResponse, response
assert_success response

assert_equal 'card_483etw4er9fg4vF3sQdrt3FG', response.authorization
assert response.test?
end

def test_successful_new_card_and_customer_update
@gateway.expects(:ssl_request).twice.returns(successful_new_card_response, successful_new_customer_response)

assert response = @gateway.store(@credit_card, :customer => 'cus_3sgheFxeBgTQ3M', :email => '[email protected]')
assert_instance_of MultiResponse, response
assert_success response

assert_equal 'card_483etw4er9fg4vF3sQdrt3FG', response.authorization
assert_equal 2, response.responses.size
assert_equal 'card_483etw4er9fg4vF3sQdrt3FG', response.responses[0].authorization
assert_equal 'cus_3sgheFxeBgTQ3M', response.responses[1].authorization
assert response.test?
end

def test_successful_new_default_card
@gateway.expects(:ssl_request).twice.returns(successful_new_card_response, successful_new_customer_response)

Expand Down

0 comments on commit 035cc65

Please sign in to comment.