Sha256: 9f38b84c45f27aefc612e2cc7599007e4dadf875ec59886e23bdbd551ce3b82d
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
require 'unit_spec_helper' describe Rpush::Adm::App do subject { Rpush::Adm::App.new(:name => 'test', :environment => 'development', :client_id => 'CLIENT_ID', :client_secret => 'CLIENT_SECRET') } let(:existing_app) { Rpush::Adm::App.create!(:name => 'existing', :environment => 'development', :client_id => 'CLIENT_ID', :client_secret => 'CLIENT_SECRET') } it 'should be valid if properly instantiated' do subject.should be_valid end it 'should be invalid if name' do subject.name = nil subject.should_not be_valid subject.errors[:name].should eq ["can't be blank"] end it 'should be invalid if name is not unique within scope' do subject.name = existing_app.name subject.should_not be_valid subject.errors[:name].should eq ["has already been taken"] end it 'should be invalid if missing client_id' do subject.client_id = nil subject.should_not be_valid subject.errors[:client_id].should eq ["can't be blank"] end it 'should be invalid if missing client_secret' do subject.client_secret = nil subject.should_not be_valid subject.errors[:client_secret].should eq ["can't be blank"] end describe '#access_token_expired?' do before(:each) do Timecop.freeze(Time.now) end after do Timecop.return end it 'should return true if access_token_expiration is nil' do subject.access_token_expired?.should be_true end it 'should return true if expired' do subject.access_token_expiration = Time.now - 5.minutes subject.access_token_expired?.should be_true end it 'should return false if not expired' do subject.access_token_expiration = Time.now + 5.minutes subject.access_token_expired?.should be_false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rpush-1.0.0-java | spec/unit/adm/app_spec.rb |
rpush-1.0.0 | spec/unit/adm/app_spec.rb |