Sha256: 37772928659e04a2c69668bede8fa37eeca17c1303f01bbf702bc6d6b2f22233
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), %w[spec_helper])) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongo_rack-0.0.5 | spec/session_hash_spec.rb |
mongo_rack-0.0.4 | spec/session_hash_spec.rb |
mongo_rack-0.0.3 | spec/session_hash_spec.rb |