Sha256: ae34793a9c14a14898248f1fe27110d04d4c68700b384dfd94183da340a6753f

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

require 'hamster/list'

describe Hamster::List do

  describe "#join" do

    describe "on a really big list" do

      before do
        @list = Hamster.interval(0, STACK_OVERFLOW_DEPTH)
      end

      it "doesn't run out of stack" do
        lambda { @list.join }.should_not raise_error
      end

    end

    describe "with a separator" do

      [
        [[], ""],
        [["A"], "A"],
        [["A", "B", "C"], "A|B|C"]
      ].each do |values, expected|

        describe "on #{values.inspect}" do

          before do
            @original = Hamster.list(*values)
            @result = @original.join("|")
          end

          it "preserves the original" do
            @original.should == Hamster.list(*values)
          end

          it "returns #{expected.inspect}" do
            @result.should == expected
          end

        end

      end

    end

    describe "without a separator" do

      [
        [[], ""],
        [["A"], "A"],
        [["A", "B", "C"], "ABC"]
      ].each do |values, expected|

        describe "on #{values.inspect}" do

          before do
            @original = Hamster.list(*values)
            @result = @original.join
          end

          it "preserves the original" do
            @original.should == Hamster.list(*values)
          end

          it "returns #{expected.inspect}" do
            @result.should == expected
          end

        end

      end

    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hamster-0.3.6 spec/hamster/list/join_spec.rb
hamster-0.3.5 spec/hamster/list/join_spec.rb
hamster-0.3.4 spec/hamster/list/join_spec.rb
hamster-0.3.3 spec/hamster/list/join_spec.rb
hamster-0.3.2 spec/hamster/list/join_spec.rb
hamster-0.3.1 spec/hamster/list/join_spec.rb
hamster-0.3.0 spec/hamster/list/join_spec.rb
hamster-0.2.13 spec/hamster/list/join_spec.rb
hamster-0.2.12 spec/hamster/list/join_spec.rb