Sha256: e398ee2f1867354e384c57cb6cfd8e21bc70658b8535de52fe887bce9a55f04e

Contents?: true

Size: 1.74 KB

Versions: 3

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

describe CandyCheck::AppStore::ReceiptCollection do
  subject { CandyCheck::AppStore::ReceiptCollection.new(attributes) }

  describe 'overdue subscription' do
    let(:attributes) do
      [{
        'expires_date' => '2014-04-15 12:52:40 Etc/GMT',
        'expires_date_pst' => '2014-04-15 05:52:40 America/Los_Angeles',
        'is_trial_period' => 'false'
      }, {
        'expires_date' => '2015-04-15 12:52:40 Etc/GMT',
        'expires_date_pst' => '2015-04-15 05:52:40 America/Los_Angeles',
        'is_trial_period' => 'false'
      }]
    end

    it 'is expired' do
      subject.expired?.must_be_true
    end

    it 'is not a trial' do
      subject.trial?.must_be_false
    end

    it 'has positive overdue days' do
      overdue = subject.overdue_days
      overdue.must_be_instance_of Fixnum
      assert overdue > 0
    end

    it 'has a last expires date' do
      expected = DateTime.new(2015, 4, 15, 12, 52, 40)
      subject.expires_at.must_equal expected
    end

    it 'is expired? at same pointin time' do
      Timecop.freeze(Time.utc(2015, 4, 15, 12, 52, 40)) do
        subject.expired?.must_be_true
      end
    end
  end

  describe 'unexpired trial subscription' do
    two_days_from_now = DateTime.now + 2

    let(:attributes) do
      [{
        'expires_date' => '2016-04-15 12:52:40 Etc/GMT',
        'is_trial_period' => 'true'
      }, {
        'expires_date' =>
          two_days_from_now.strftime('%Y-%m-%d %H:%M:%S Etc/GMT'),
        'is_trial_period' => 'true'
      }]
    end

    it 'has not expired' do
      subject.expired?.must_be_false
    end

    it 'it is a trial' do
      subject.trial?.must_be_true
    end

    it 'expires in two days' do
      subject.overdue_days.must_equal(-2)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
candy_check-0.2.0 spec/app_store/receipt_collection_spec.rb
candy_check-0.1.2 spec/app_store/receipt_collection_spec.rb
candy_check-0.1.1 spec/app_store/receipt_collection_spec.rb