Sha256: 26f831c6b18cf2840d58653013cdbd50ef6dd2467f8c620849d8f990c1e3298d

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

require 'hamster/stack'

describe Hamster::Stack do

  describe "#pop" do

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

      describe "on #{values.inspect}" do

        before do
          @original = Hamster.stack(*values)
          @result = @original.pop
        end

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

        it "returns #{expected.inspect}" do
          @result.should == Hamster.stack(*expected)
        end

      end

    end

    [
      [],
      ["A"],
    ].each do |values|

      describe "on #{values.inspect}" do

        before do
          @original = Hamster.stack(*values)
          @result = @original.pop
        end

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

        it "returns the empty stack" do
          @result.should equal(Hamster.stack)
        end

      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hamster-0.1.19 spec/hamster/stack/pop_spec.rb
hamster-0.1.18 spec/hamster/stack/pop_spec.rb
hamster-0.1.17 spec/hamster/stack/pop_spec.rb
hamster-0.1.16 spec/hamster/stack/pop_spec.rb
hamster-0.1.15 spec/hamster/stack/pop_spec.rb