Sha256: cf75e4d4a356cba7f50ad4adc4f186342fe00e613f4d0ee4676b460edba58f29

Contents?: true

Size: 1.31 KB

Versions: 25

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

# # Attributes
describe Effective::Providers::StripeCharge do
  let(:order) { FactoryGirl.create(:order_with_subscription) }
  let(:charge) { Effective::Providers::StripeCharge.new(order) }

  before { StripeMock.start }
  after { StripeMock.stop }

  it 'can be initialized with an order' do
    charge = Effective::Providers::StripeCharge.new(order)
    charge.order.should eq order
    charge.effective_order_id.should eq order.to_param
  end

  it 'can be initialized without an order' do
    charge = Effective::Providers::StripeCharge.new(:token => 'tok_123', :effective_order_id => 3)
    charge.token.should eq 'tok_123'
    charge.effective_order_id.should eq 3
    charge.order.nil?.should eq true
  end

  it 'performs validations' do
    charge = Effective::Providers::StripeCharge.new()
    charge.valid?.should eq false
    charge.errors[:token].present?.should eq true
    charge.errors[:effective_order_id].present?.should eq true
  end

  it '#order_items returns all OrderItems where the purchasable is not a Subscription' do
    charge.order_items.all? { |oi| oi.purchasable_type != 'Effective::Subscription'}.should eq true
  end

  it '#subscriptions returns all Subscriptions (not order items)' do
    charge.subscriptions.all? { |oi| oi.kind_of?(Effective::Subscription) }.should eq true
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
effective_orders-3.0.0 spec/models/stripe_charge_spec.rb
effective_orders-2.2.4 spec/models/stripe_charge_spec.rb
effective_orders-2.2.3 spec/models/stripe_charge_spec.rb
effective_orders-2.2.2 spec/models/stripe_charge_spec.rb
effective_orders-2.2.1 spec/models/stripe_charge_spec.rb
effective_orders-2.2.0 spec/models/stripe_charge_spec.rb
effective_orders-2.1.17 spec/models/stripe_charge_spec.rb
effective_orders-2.1.16 spec/models/stripe_charge_spec.rb
effective_orders-2.1.15 spec/models/stripe_charge_spec.rb
effective_orders-2.1.14 spec/models/stripe_charge_spec.rb
effective_orders-2.1.13 spec/models/stripe_charge_spec.rb
effective_orders-2.1.12 spec/models/stripe_charge_spec.rb
effective_orders-2.1.10 spec/models/stripe_charge_spec.rb
effective_orders-2.1.9 spec/models/stripe_charge_spec.rb
effective_orders-2.1.8 spec/models/stripe_charge_spec.rb
effective_orders-2.1.7 spec/models/stripe_charge_spec.rb
effective_orders-2.1.6 spec/models/stripe_charge_spec.rb
effective_orders-2.1.5 spec/models/stripe_charge_spec.rb
effective_orders-2.1.4 spec/models/stripe_charge_spec.rb
effective_orders-2.1.3 spec/models/stripe_charge_spec.rb