File: inspect_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 (30 lines) | stat: -rw-r--r-- 908 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
22
23
24
25
26
27
28
29
30
require 'spec_helper'

describe Immutable::Hash do
  describe '#inspect' do
    [
      [[], 'Immutable::Hash[]'],
      [['A' => 'aye'], 'Immutable::Hash["A" => "aye"]'],
      [[DeterministicHash.new('A', 1) => 'aye', DeterministicHash.new('B', 2) => 'bee', DeterministicHash.new('C', 3) => 'see'], 'Immutable::Hash["A" => "aye", "B" => "bee", "C" => "see"]']
    ].each do |values, expected|
      describe "on #{values.inspect}" do
        it "returns #{expected.inspect}" do
          H[*values].inspect.should == expected
        end
      end
    end

    [
      {},
      {'A' => 'aye'},
      {a: 'aye', b: 'bee', c: 'see'}
    ].each do |values|
      describe "on #{values.inspect}" do
        it "returns a string which can be eval'd to get an equivalent object" do
          original = H.new(values)
          eval(original.inspect).should eql(original)
        end
      end
    end
  end
end