File: to_list_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 (35 lines) | stat: -rw-r--r-- 747 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
31
32
33
34
35
require 'spec_helper'

describe Immutable::Set do
  describe '#to_list' do
    [
      [],
      ['A'],
      %w[A B C],
    ].each do |values|
      context "on #{values.inspect}" do
        let(:set) { S[*values] }
        let(:list) { set.to_list }

        it 'returns a list' do
          list.is_a?(Immutable::List).should == true
        end

        it "doesn't change the original Set" do
          list
          set.should eql(S.new(values))
        end

        describe 'the returned list' do
          it 'has the correct length' do
            list.size.should == values.size
          end

          it 'contains all values' do
            list.to_a.sort.should == values.sort
          end
        end
      end
    end
  end
end