Sha256: 310265c90b0eccfed223b81c8183a349d0ce2893f83ad2bf5ee0218ae9afdc7f
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require_relative "spec_helper" describe Hash do describe :instance do before(:each) do @result_data = { 'one_level' => 'SUCCESS', 'three_level' => { 'level_two' => { 'level_one' => 'HOORAY' } } } end it "responds to get_leaf" do @result_data.respond_to?(:get_leaf).must_equal true end it "gets a single level's node" do @result_data.get_leaf('one_level').must_equal 'SUCCESS' end it "gets a deeply nested node" do @result_data.get_leaf('three_level', 'level_two', 'level_one').must_equal 'HOORAY' end it "responds with nil for a shallow missing node" do @result_data.get_leaf('missing').must_be_nil end it "responds with nil for a deep missing node" do @result_data.get_leaf('three_level', 'level_two', 'missing').must_be_nil end it "responds with nil when it encounters a non-hash in the path" do @result_data.get_leaf('three_level', 'level_two', 'level_one', 'level_zero').must_be_nil end it "evaluates a block instead of returning nil if a block is given" do @result_data.get_leaf('nope') { 'potato' }.must_equal 'potato' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
deep_tree-0.0.3 | spec/hash_spec.rb |
deep_tree-0.0.2 | spec/hash_spec.rb |
deep_tree-0.0.1 | spec/hash_spec.rb |