File: to_hash_spec.rb

package info (click to toggle)
ruby-immutable-ruby 0.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,852 kB
  • sloc: ruby: 16,556; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 568 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'spec_helper'

describe Immutable::Hash do
  [:to_hash, :to_h].each do |method|
    describe "##{method}" do
      it 'converts an empty Immutable::Hash to an empty Ruby Hash' do
        H.empty.send(method).should eql({})
      end

      it 'converts a non-empty Immutable::Hash to a Hash with the same keys and values' do
        H[a: 1, b: 2].send(method).should eql({a: 1, b: 2})
      end

      it "doesn't modify the receiver" do
        hash = H[a: 1, b: 2]
        hash.send(method)
        hash.should eql(H[a: 1, b: 2])
      end
    end
  end
end