Sha256: dacb182a5a465180c3bf8da40c0caf60c607b2a02adb620b5e325168c1a872a3

Contents?: true

Size: 1.54 KB

Versions: 16

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe Chargify::Customer, :fake_resource do
  context '.find_by_reference' do
    let(:existing_customer) { Chargify::Customer.create(:id => 5, :reference => 'sigma') }

    before(:each) do
      FakeWeb.register_uri(:get, "#{test_domain}/customers/lookup.xml?reference=sigma", :body => existing_customer.attributes.to_xml)
    end

    it 'finds the correct customer by reference' do
      customer = Chargify::Customer.find_by_reference('sigma')
      customer.should == existing_customer
    end

    it 'is an instance of Chargify::Customer' do
      customer = Chargify::Customer.find_by_reference('sigma')
      customer.should be_instance_of(Chargify::Customer)
    end

    it 'is marked as persisted' do
      customer = Chargify::Customer.find_by_reference('sigma')
      customer.persisted?.should == true
    end
  end

  context "#subscriptions" do
    let(:customer)       { Chargify::Customer.create(:id => 5, :reference => 'sigma') }
    let(:subscription_1) { Chargify::Customer::Subscription.create(:customer_id => customer.id, :balance_in_cents => 4999) }
    let(:subscription_2) { Chargify::Customer::Subscription.create(:customer_id => customer.id, :balance_in_cents => 2499) }

    before(:each) do
      FakeWeb.register_uri(:get, "#{test_domain}/customers/#{customer.id}/subscriptions.xml", :body => [subscription_1.attributes, subscription_2.attributes].to_xml)
    end

    it "returns the subscriptions belonging to the customer" do
      customer.subscriptions.should =~ [subscription_1, subscription_2]
    end
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
chargify_api_ares-1.4.7 spec/resources/customer_spec.rb
chargify_api_ares-1.4.6 spec/resources/customer_spec.rb
chargify_api_ares-1.4.5 spec/resources/customer_spec.rb
chargify_api_ares-1.4.4 spec/resources/customer_spec.rb
chargify_api_ares-1.4.3 spec/resources/customer_spec.rb
chargify_api_ares-1.4.2 spec/resources/customer_spec.rb
chargify_api_ares-1.4.1 spec/resources/customer_spec.rb
chargify_api_ares-1.4.0 spec/resources/customer_spec.rb
chargify_api_ares-1.3.5 spec/resources/customer_spec.rb
chargify_api_ares-1.3.4 spec/resources/customer_spec.rb
chargify_api_ares-1.3.3 spec/resources/customer_spec.rb
chargify_api_ares-1.3.2 spec/resources/customer_spec.rb
chargify_api_ares-1.3.1 spec/resources/customer_spec.rb
chargify_api_ares-1.3.0 spec/resources/customer_spec.rb
chargify_api_ares-1.2.1 spec/resources/customer_spec.rb
chargify_api_ares-1.1.0 spec/resources/customer_spec.rb