1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
require 'spec_helper'
describe Immutable::Hash do
let(:hash) { H['A' => 'aye', 'B' => 'bee', 'C' => 'see'] }
describe '#reverse_each' do
context 'with a block' do
it 'returns self' do
hash.reverse_each {}.should be(hash)
end
it 'yields all key/value pairs in the opposite order as #each' do
result = []
hash.reverse_each { |entry| result << entry }
result.should eql(hash.to_a.reverse)
end
end
context 'with no block' do
it 'returns an Enumerator' do
result = hash.reverse_each
result.class.should be(Enumerator)
result.to_a.should eql(hash.to_a.reverse)
end
end
end
end
|