Sha256: 3375d6738786389ea2627b458a16dad6fbb0be6c92102548c6ede67eb7bc2dfa

Contents?: true

Size: 1.26 KB

Versions: 64

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

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

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

  it 'can be initialized with an order' do
    charge = Effective::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::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::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

64 entries across 64 versions & 1 rubygems

Version Path
effective_orders-1.5.2 spec/models/stripe_charge_spec.rb
effective_orders-1.5.1 spec/models/stripe_charge_spec.rb
effective_orders-1.5.0 spec/models/stripe_charge_spec.rb
effective_orders-1.4.8 spec/models/stripe_charge_spec.rb
effective_orders-1.4.7 spec/models/stripe_charge_spec.rb
effective_orders-1.4.6 spec/models/stripe_charge_spec.rb
effective_orders-1.4.5 spec/models/stripe_charge_spec.rb
effective_orders-1.4.4 spec/models/stripe_charge_spec.rb
effective_orders-1.4.3 spec/models/stripe_charge_spec.rb
effective_orders-1.4.2 spec/models/stripe_charge_spec.rb
effective_orders-1.4.1 spec/models/stripe_charge_spec.rb
effective_orders-1.4.0 spec/models/stripe_charge_spec.rb
effective_orders-1.3.13 spec/models/stripe_charge_spec.rb
effective_orders-1.3.12 spec/models/stripe_charge_spec.rb
effective_orders-1.3.11 spec/models/stripe_charge_spec.rb
effective_orders-1.3.10 spec/models/stripe_charge_spec.rb
effective_orders-1.3.9 spec/models/stripe_charge_spec.rb
effective_orders-1.3.8 spec/models/stripe_charge_spec.rb
effective_orders-1.3.7 spec/models/stripe_charge_spec.rb
effective_orders-1.3.6 spec/models/stripe_charge_spec.rb