Sha256: f8fbfbd8853055a2c6350001cb1f8b4bc100d686fd56b58f6dd273e85fb68e76

Contents?: true

Size: 920 Bytes

Versions: 7

Compression:

Stored size: 920 Bytes

Contents

require 'spec_helper'

module Cellect::Server
  describe User do
    let(:user){ User.new 1, workflow_name: 'random' }
    
    it 'should store seen ids' do
      expect(user.seen).to be_a DiffSet::RandomSet
    end
    
    it 'should have a default ttl of 15 minutes' do
      expect(user.ttl).to eq 900 # seconds
    end
    
    it 'should allow custom ttl' do
      expect(User.new(2, workflow_name: 'random', ttl: 123).ttl).to eq 123
    end
    
    it 'should reset the ttl timer on activity' do
      expect(user.bare_object).to receive(:restart_ttl_timer).at_least :once
      user.seen
    end
    
    it 'should terminate on ttl expiry' do
      async_workflow = double
      expect(Workflow[user.workflow_name]).to receive(:async).and_return async_workflow
      expect(async_workflow).to receive(:remove_user).with user.id
      user.ttl_expired!
      expect(user.ttl_timer).to be_nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cellect-server-0.1.3 spec/server/user_spec.rb
cellect-server-0.1.2.pre.jruby spec/server/user_spec.rb
cellect-server-0.1.2 spec/server/user_spec.rb
cellect-server-0.1.1 spec/server/user_spec.rb
cellect-server-0.1.0 spec/server/user_spec.rb
cellect-server-0.0.9 spec/server/user_spec.rb
cellect-server-0.0.8 spec/server/user_spec.rb