Sha256: f8d2390003926421a2961c315bc3bc3a1f2a903dfcf4e559f293d70d8e15a135

Contents?: true

Size: 1.58 KB

Versions: 20

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe Analytical::SessionCommandStore do
  
  describe 'with a session hash' do
    before(:each) do
      @session = {}
    end
    
    it 'should add elements' do
      @store = Analytical::SessionCommandStore.new @session, :some_module, ['a']
      @store << 'b'
      @session[:analytical_some_module].should == ['a', 'b']
    end
    it 'should unshift elements' do
      @store = Analytical::SessionCommandStore.new @session, :some_module, ['b']
      @store.unshift 'a'
      @session[:analytical_some_module].should == ['a', 'b']
    end
    it 'should iterate over elements' do
      @store = Analytical::SessionCommandStore.new @session, :some_module, ['a', 'b']
      @store.each do |elem|
        ['a', 'b'].include?(elem).should be_true
      end
    end
    it 'should have size' do
      @store = Analytical::SessionCommandStore.new @session, :some_module, ['a', 'b']
      @store.size.should == 2
    end

    it 'should set up the :analytical session hash' do
      @store = Analytical::SessionCommandStore.new @session, :some_module, ['a', 'b']
      @session[:analytical_some_module].should_not be_nil   
    end

    describe 'when flushing' do
      it 'should empty the list' do
        @store = Analytical::SessionCommandStore.new @session, :some_module, ['a', 'b']
        @store.flush
        @store.size.should == 0
      end
      it 'should empty the session key' do
        @store = Analytical::SessionCommandStore.new @session, :some_module, ['a', 'b']
        @store.flush
        @session[:analytical_some_module].should == []
      end
    end
  end
  
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
analytical-3.0.8 spec/analytical/session_command_store_spec.rb
analytical-3.0.7 spec/analytical/session_command_store_spec.rb
analytical-3.0.6 spec/analytical/session_command_store_spec.rb
gsiener-analytical-2.10.2 spec/analytical/session_command_store_spec.rb
gsiener-analytical-2.10.1 spec/analytical/session_command_store_spec.rb
analytical-2.11.0 spec/analytical/session_command_store_spec.rb
analytical-2.10.0 spec/analytical/session_command_store_spec.rb
gsiener-analytical-2.10.0 spec/analytical/session_command_store_spec.rb
analytical-2.9.0 spec/analytical/session_command_store_spec.rb
analytical-2.8.0 spec/analytical/session_command_store_spec.rb
analytical-2.7.2 spec/analytical/session_command_store_spec.rb
analytical-2.7.1 spec/analytical/session_command_store_spec.rb
analytical-2.7.0 spec/analytical/session_command_store_spec.rb
analytical-2.6.0 spec/analytical/session_command_store_spec.rb
analytical-2.5.0 spec/analytical/session_command_store_spec.rb
analytical-2.4.0 spec/analytical/session_command_store_spec.rb
analytical-2.3.0 spec/analytical/session_command_store_spec.rb
analytical-2.2.0 spec/analytical/session_command_store_spec.rb
analytical-2.1.0 spec/analytical/session_command_store_spec.rb
analytical-2.0.0 spec/analytical/session_command_store_spec.rb