Sha256: c752e8debd70b062dcc8202437cae930543eb7df2cc1152c074b5cdc8b28a253

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

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

describe BraintreeRails::Addresses do
  before do
    stub_braintree_request(:get, '/customers/customer_id', :body => fixture('customer.xml'))
  end

  describe '#initialize' do
    it 'should wrap an array of Braintree::Address' do
      braintree_customer = Braintree::Customer.find('customer_id')
      braintree_addresses = braintree_customer.addresses
      addresses = BraintreeRails::Addresses.new(braintree_customer, braintree_addresses)
      
      addresses.size.must_equal braintree_addresses.size

      braintree_addresses.each do |braintree_address|
        address = addresses.find(braintree_address.id)
        BraintreeRails::Address::Attributes.each do |attribute|
          address.send(attribute).must_equal braintree_address.send(attribute)
        end
      end
    end
  end

  describe '#build' do
    it 'should build new Address object with customer_id and params' do
      braintree_customer = Braintree::Customer.find('customer_id')
      braintree_addresses = braintree_customer.addresses
      addresses = BraintreeRails::Addresses.new(braintree_customer, braintree_addresses)
      address = addresses.build({:first_name => 'foo', :last_name => 'bar'})

      address.persisted?.must_equal false
      address.customer_id.must_equal braintree_customer.id
      address.first_name.must_equal 'foo'
      address.last_name.must_equal 'bar'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
braintree-rails-0.2.0 test/unit/braintree_rails/addresses_test.rb
braintree-rails-0.1.0 test/unit/braintree_rails/addresses_test.rb
braintree-rails-0.0.2 test/unit/braintree_rails/addresses_test.rb
braintree-rails-0.0.1 test/unit/braintree_rails/addresses_test.rb