Sha256: 1d7be070444c7889034684df57b27118bf087f52dd536cd52c7e6aad36072981
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require File.expand_path( File.join( File.dirname(__FILE__), %w[spec_helper] ) ) require File.expand_path( File.join( File.dirname(__FILE__), %w[.. lib core_ext hash] ) ) describe MongoRack::SessionHash do before :all do @sessions = MongoRack::SessionHash.new( :fred => 10, :blee => "duh", 'crap' => 20 ) end it "should pass non hash arg to hash class correctly" do hash = MongoRack::SessionHash.new( "BumbleBeeTuna" ) hash[:c].should == "BumbleBeeTuna" end describe "indiscrement access" do it "should find a symbol keys correctly" do @sessions[:fred].should == 10 @sessions[:blee].should == "duh" end it "should find a string key correctly" do @sessions['fred'].should == 10 @sessions[:crap].should == 20 @sessions.fetch(:crap).should == @sessions.fetch('crap') end it "should return nil if a key is not in the hash" do @sessions[:zob].should be_nil end it "should find values at indices correctly" do @sessions.values_at( :fred, :blee ).should == [10, 'duh'] @sessions.values_at( 'fred', 'blee' ).should == [10, 'duh'] @sessions.values_at( :fred, 'blee' ).should == [10, 'duh'] end it "should convert sub hashes correctly" do @sessions[:blee] = { "bobo" => 10, :ema => "Hello" } @sessions[:blee][:bobo].should == 10 @sessions[:blee]['ema'].should == "Hello" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo_rack-0.0.2 | spec/session_hash_spec.rb |