Sha256: 0589dc6c892c018232ac2eed49ff2f40bfce422a5263321a67a234b429277a9b

Contents?: true

Size: 748 Bytes

Versions: 37

Compression:

Stored size: 748 Bytes

Contents

require 'spec_helper'
require 'sugar-high/hash'

describe "SugarHigh" do
  describe "Hash packet" do
    describe '#hash_revert' do    
      it "should revert hash" do
        {:a => 'hello', :b => 'hi', :c => 'hi'}.hash_revert.should == {'hello' => [:a], 'hi' => [:b, :c]}
      end

      it "should try keys in hash until triggered" do
        {:a => 'hello', :b => 'hi'}.try_keys([:x, :a, :b]).should == 'hello'
      end

      it "should return nil if no key triggered" do
        {:a => 'hello', :b => 'hi'}.try_keys([:x, :y, :z]).should == nil
      end

      it "should return nil if no key triggered" do
        {:a => 'hello', :b => 'hi'}.try_keys([:x, :y, :z], :default => 'none').should == 'none'
      end
    end        
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
sugar-high-0.6.0 spec/sugar-high/hash_spec.rb
sugar-high-0.5.5 spec/sugar-high/hash_spec.rb
sugar-high-0.5.4 spec/sugar-high/hash_spec.rb
sugar-high-0.5.3 spec/sugar-high/hash_spec.rb
sugar-high-0.5.1 spec/sugar-high/hash_spec.rb
sugar-high-0.5.0 spec/sugar-high/hash_spec.rb
sugar-high-0.4.9.5 spec/sugar-high/hash_spec.rb
sugar-high-0.4.9.3 spec/sugar-high/hash_spec.rb
sugar-high-0.4.9.2 spec/sugar-high/hash_spec.rb
sugar-high-0.4.9.1 spec/sugar-high/hash_spec.rb
sugar-high-0.4.9 spec/sugar-high/hash_spec.rb
sugar-high-0.4.8 spec/sugar-high/hash_spec.rb
sugar-high-0.4.7 spec/sugar-high/hash_spec.rb
sugar-high-0.4.6.4 spec/sugar-high/hash_spec.rb
sugar-high-0.4.6.3 spec/sugar-high/hash_spec.rb
sugar-high-0.4.6.2 spec/sugar-high/hash_spec.rb
sugar-high-0.4.6.1 spec/sugar-high/hash_spec.rb
sugar-high-0.4.6 spec/sugar-high/hash_spec.rb
sugar-high-0.4.5.2 spec/sugar-high/hash_spec.rb
sugar-high-0.4.5 spec/sugar-high/hash_spec.rb