Sha256: 489fd647873a2add1e0dca37de99dfbff9933fbb1990057fa2abd1059d42f86d

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '../integration_test_helper'))

describe 'Customer Integration' do
  before do
    Braintree::Customer.all.each { |c| Braintree::Customer.delete c.id }
  end

  it 'should fetch customer from Braintree for given id' do
    braintree_customer = Braintree::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
    customer = BraintreeRails::Customer.new(braintree_customer.id)
    customer.id.must_equal braintree_customer.id
    customer.first_name.must_equal 'Brain'
    customer.last_name.must_equal 'Tree'
    customer.persisted?.must_equal true
  end

  it 'should be able to create new customer' do
    customer = BraintreeRails::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
    braintree_customer = Braintree::Customer.find(customer.id)

    braintree_customer.first_name.must_equal 'Brain'
    braintree_customer.last_name.must_equal 'Tree'
  end

  it 'should be able to update existing customer' do
    customer = BraintreeRails::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
    customer.update_attributes!(:first_name => 'Foo', :last_name => 'Bar')

    braintree_customer = Braintree::Customer.find(customer.id)
    braintree_customer.first_name.must_equal 'Foo'
    braintree_customer.last_name.must_equal 'Bar'
  end

  it 'should be able to destroy existing customer' do
    customer = BraintreeRails::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
    customer.destroy!
    lambda{ Braintree::Customer.find(customer.id) }.must_raise Braintree::NotFoundError
    customer.persisted?.must_equal false
    customer.frozen?.must_equal true
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
braintree-rails-0.3.0 test/integration/braintree_rails/customer_integration_test.rb
braintree-rails-0.2.0 test/integration/braintree_rails/customer_integration_test.rb
braintree-rails-0.1.0 test/integration/braintree_rails/customer_integration_test.rb
braintree-rails-0.0.2 test/integration/braintree_rails/customer_integration_test.rb
braintree-rails-0.0.1 test/integration/braintree_rails/customer_integration_test.rb