Sha256: d7d09b6cca452e75114560c6101b82fa58b7c6690ad71a2ee4bdd7a26bbe0b5c

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 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

1 entries across 1 versions & 1 rubygems

Version Path
stripe_local-0.0.2 spec/models/stripe_local/balance_spec.rb