Sha256: e56c2c7a873bbc3abcaca8a458a7598f80523d3593c76e7f7fe885fc0694430b

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

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

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 an empty stack" do
          @result.should be_empty
        end

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.2.7 spec/hamster/stack/pop_spec.rb
hamster-0.2.6 spec/hamster/stack/pop_spec.rb