Sha256: 003d58660f81d60fa9bab62cfa3be9591713385040dd4056bc69945911b81da4
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 KB
Contents
require 'spec_helper' describe Hashugar do context 'when accessing simple hash' do it 'should be make accessible string and symbol keys' do hashugar = {:a => 1, 'b' => 2}.to_hashugar hashugar.a.should == 1 hashugar.b.should == 2 end it 'should be readable through nice methods' do hashugar = {:a => 1, :b => 2}.to_hashugar hashugar.a.should == 1 hashugar.b.should == 2 end it 'should be writable through nice methods' do hashugar = {:a => 1}.to_hashugar hashugar.a = 2 hashugar.b = 3 hashugar.a.should == 2 hashugar.b.should == 3 end it 'should be readable through old methods' do hashugar = {:a => 1}.to_hashugar hashugar[:a].should == 1 hashugar['a'].should == 1 end it 'should be writable through old methods' do hashugar = {:a => 1}.to_hashugar hashugar['a'] = 2 hashugar.a.should == 2 hashugar[:a] = 3 hashugar.a.should == 3 end end context 'when accessing nested hash' do it 'should be writable through nice methods' do hashugar = {:a => {:b => 1}}.to_hashugar hashugar.a.b.should == 1 end it 'should be writable through nice methods' do hashugar = {:a =>{}}.to_hashugar hashugar.a.b = 1 hashugar.a.b.should == 1 end end context 'when accessing hashes in array' do it 'should return hashugars' do hashugar = [{:a => 1}, {:b => 2}].to_hashugar hashugar[0].a.should == 1 hashugar.last.b.should == 2 end end context 'when using respond_to?' do it 'should return true on valid key' do hashugar = {:a => 1}.to_hashugar hashugar.respond_to?('a').should be_true hashugar.respond_to?(:a).should be_true hashugar.respond_to?(:b).should be_false end end context 'when creating using Hashugar#new' do it 'should accept hash in contructor' do hashugar = Hashugar.new({:a => {:b => 1}}) hashugar.a.b.should == 1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hashugar-0.0.5 | spec/hashugar_spec.rb |
hashugar-0.0.4 | spec/hashugar_spec.rb |