File: construction_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 (29 lines) | stat: -rw-r--r-- 708 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
require 'spec_helper'

describe Immutable::Deque do
  describe '.[]' do
    context 'with no arguments' do
      it 'always returns the same instance' do
        D[].class.should be(Immutable::Deque)
        D[].should equal(D[])
      end

      it 'returns an empty, frozen deque' do
        D[].should be_empty
        D[].should be_frozen
      end
    end

    context 'with a number of items' do
      let(:deque) { D['A', 'B', 'C'] }

      it 'always returns a different instance' do
        deque.should_not equal(D['A', 'B', 'C'])
      end

      it 'is the same as repeatedly using #endeque' do
        deque.should eql(D.empty.enqueue('A').enqueue('B').enqueue('C'))
      end
    end
  end
end