spec/locale_tree/siblings_spec.rb in i18n-tasks-0.7.11 vs spec/locale_tree/siblings_spec.rb in i18n-tasks-0.7.12

- old
+ new

@@ -4,16 +4,36 @@ describe 'Tree siblings / forest' do context 'Node' do it '::new with children' do children = I18n::Tasks::Data::Tree::Siblings.from_key_attr([['a', value: 1]]) - node = I18n::Tasks::Data::Tree::Node.new( + node = new_node( key: 'fr', children: children ) expect(node.to_siblings.first.children.parent.key).to eq 'fr' end + + it '== (false by value)' do + expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not( + eq(build_node({'a' => {'b' => {'c' => 2}}}))) + end + + it '== (false by key)' do + expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not( + eq(build_node({'a' => {'b' => {'d' => 1}}}))) + end + + it '== (false by children)' do + expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not( + eq(build_node({'a' => {'b' => {'c' => 1}, 'x' => 2}}))) + end + + it '== (true)' do + expect(build_node({'a' => {'b' => {'c' => 1}, 'x' => 2}})).to_not( + eq(build_node({'a' => {'b' => {'d' => 1}, 'x' => 2}}))) + end end context 'a tree' do let(:a_hash) { {'a' => 1, 'b' => {'ba' => 1, 'bb' => 2}} } @@ -53,11 +73,11 @@ expect { silence_stderr { a.merge(b) } }.to_not raise_error end it '#set conflict value <- scope' do a = build_tree(a: 1) - expect { silence_stderr { a.set('a.b', build_node(key: 'b', value: 1)) } }.to_not raise_error + expect { silence_stderr { a.set('a.b', new_node(key: 'b', value: 1)) } }.to_not raise_error end it '#intersect' do x = {a: 1, b: {ba: 1, bb: 2}} y = {b: {ba: 1, bc: 3}, c: 1} @@ -70,21 +90,21 @@ it '#select_keys' do expect(build_tree(a: 1, b: 1).select_keys {|k, node| k == 'b'}.to_hash).to eq({'b' => 1}) end it '#append!' do - expect(build_tree({'a' => 1}).append!(build_node(key: 'b', value: 2)).to_hash).to eq('a' => 1, 'b' => 2) + expect(build_tree({'a' => 1}).append!(new_node(key: 'b', value: 2)).to_hash).to eq('a' => 1, 'b' => 2) end it '#set replace value' do - expect(build_tree(a: {b: 1}).tap {|t| t['a.b'] = build_node(key: 'b', value: 2) }.to_hash).to( + expect(build_tree(a: {b: 1}).tap {|t| t['a.b'] = new_node(key: 'b', value: 2) }.to_hash).to( eq('a' => {'b' => 2}) ) end it '#set get' do t = build_tree(a: {x: 1}) - node = build_node(key: 'd', value: 'e') + node = new_node(key: 'd', value: 'e') t['a.b.c.' + node.key] = node expect(t['a.b.c.d'].value).to eq('e') end it '#inspect' do