Sha256: ac0960119b2efe4e4dee85bc0ea1767b6c3e3be8ada93985fe55ff2a9561837b

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

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

describe Hamster::Stack do

  describe "#push" do

    before do
      @original = Hamster::Stack.new.push("A")
      @copy = @original.push("B")
    end

    it "returns a modified copy" do
      @copy.should_not equal(@original)
    end

    describe "the original" do

      it "still has the original top" do
        @original.top.should == "A"
      end

      it "still has the original size" do
        @original.size.should == 1
      end

    end

    describe "the modified copy" do

      it "has a new top" do
        @copy.top.should == "B"
      end

      it "size is increased by one" do
        @copy.size == 2
      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.1.8 spec/hamster/stack/push_spec.rb
hamster-0.1.7 spec/hamster/stack/push_spec.rb
hamster-0.1.6 spec/hamster/stack/push_spec.rb
hamster-0.1.5 spec/hamster/stack/push_spec.rb