spec/sugar-high/hash_spec.rb in sugar-high-0.6.3 vs spec/sugar-high/hash_spec.rb in sugar-high-0.7.0
- old
+ new
@@ -8,13 +8,18 @@
mapping = {:a => :new_a, :b => :new_b}
{:a => 'hello', :b => 'hi', :c => 'hi'}.rewrite(mapping).should == {:new_a => 'hello', :new_b => 'hi', :c => 'hi'}
end
end
- describe '#hash_revert' do
+ describe '#hash_revert' do
+ # The way 1.8.7 orders Hashes is really strange. It is hard to write straight expectation here
it "should revert hash" do
- {:a => 'hello', :b => 'hi', :c => 'hi'}.hash_revert.should == {'hello' => [:a], 'hi' => [:b, :c]}
+ reverted_hash = {:a => 'hello', :b => 'hi', :c => 'hi'}.hash_revert
+ reverted_hash['hello'].should == [:a]
+
+ reverted_hash['hi'].should include :b, :c
+ reverted_hash['hi'].size.should == 2
end
it "should try keys in hash until triggered" do
{:a => 'hello', :b => 'hi'}.try_keys([:x, :a, :b]).should == 'hello'
end
@@ -24,8 +29,8 @@
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
end