Sha256: 19910bfb09f323b5bf8621f3f6bc853f41ca68948a6a8b1f35fb395ea238f255

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe StripeLocal::Balance do

	before do
		StripeLocal::Balance.create pending: 29900, available:  9900
		StripeLocal::Balance.create pending: 19900, available: 19900
	end

	subject { StripeLocal::Balance }

	its( :current )  { should be 19900 }

	its( :previous ) { should be  9900 }

	its( :changed )  { should be 10000 }

	its( :pending )  { should be 19900 }

	its( :previous_pending ) { should be 29900 }

  describe "redundant `StripeLocal::balance.available` webhook is received" do
    before do
      @count = StripeLocal::Balance.count
      @updated = StripeLocal::Balance.last.updated_at.to_i
    end
    before { Timecop.travel 1.day.from_now }
    after  { Timecop.return }

    it "keeps StripeLocal::Balance updated, but doesn't create redundant records" do
      StripeLocal::Balance.event({ pending: 19900, available: 19900 })

      StripeLocal::Balance.count.should eq @count
      StripeLocal::Balance.last.updated_at.to_i.should > @updated
    end
  end

	describe "`balance.available` webhook signifies a changed balance" do
		before { @count = StripeLocal::Balance.count }

		it "creates a new record" do
			StripeLocal::Balance.event({ pending: 0, available: 39800 })

			StripeLocal::Balance.count.should eq @count + 1
		end
	end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stripe_local-0.2.5 spec/models/stripe_local/balance_spec.rb
stripe_local-0.2.4 spec/models/stripe_local/balance_spec.rb
stripe_local-0.2.3 spec/models/stripe_local/balance_spec.rb
stripe_local-0.2.2 spec/models/stripe_local/balance_spec.rb
stripe_local-0.2.1 spec/models/stripe_local/balance_spec.rb
stripe_local-0.2.0 spec/models/stripe_local/balance_spec.rb
stripe_local-0.1.3 spec/models/stripe_local/balance_spec.rb
stripe_local-0.1.2 spec/models/stripe_local/balance_spec.rb
stripe_local-0.1.1 spec/models/stripe_local/balance_spec.rb
stripe_local-0.1.0 spec/models/stripe_local/balance_spec.rb