Sha256: e6286bff526af7414847446d3dbf0db0e7a078b2a21bb77a6bf47dd70e6119c0

Contents?: true

Size: 912 Bytes

Versions: 54

Compression:

Stored size: 912 Bytes

Contents

require File.join(File.dirname(__FILE__), *%w[spec_helper])

shared_examples_for "non-empty Stack" do

  it { @stack.should_not be_empty }
  
  it "should return the top item when sent #peek" do
    @stack.peek.should == @last_item_added
  end

  it "should NOT remove the top item when sent #peek" do
    @stack.peek.should == @last_item_added
    @stack.peek.should == @last_item_added
  end
  
  it "should return the top item when sent #pop" do
    @stack.pop.should == @last_item_added
  end
  
  it "should remove the top item when sent #pop" do
    @stack.pop.should == @last_item_added
    unless @stack.empty?
      @stack.pop.should_not == @last_item_added
    end
  end
  
end

shared_examples_for "non-full Stack" do

  it { @stack.should_not be_full }

  it "should add to the top when sent #push" do
    @stack.push "newly added top item"
    @stack.peek.should == "newly added top item"
  end

end

Version data entries

54 entries across 54 versions & 9 rubygems

Version Path
dchelimsky-rspec-1.1.10 examples/pure/shared_stack_examples.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/examples/pure/shared_stack_examples.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/examples/pure/shared_stack_examples.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/examples/pure/shared_stack_examples.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/examples/pure/shared_stack_examples.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/examples/pure/shared_stack_examples.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/examples/pure/shared_stack_examples.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/examples/pure/shared_stack_examples.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/examples/pure/shared_stack_examples.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/examples/pure/shared_stack_examples.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/examples/pure/shared_stack_examples.rb
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/examples/pure/shared_stack_examples.rb
picolena-0.1.1 rails_plugins/rspec/examples/pure/shared_stack_examples.rb
picolena-0.1.0 rails_plugins/rspec/examples/pure/shared_stack_examples.rb
picolena-0.1.2 rails_plugins/rspec/examples/pure/shared_stack_examples.rb
picolena-0.1.3 rails_plugins/rspec/examples/pure/shared_stack_examples.rb
picolena-0.1.4 rails_plugins/rspec/examples/pure/shared_stack_examples.rb
picolena-0.1.5 rails_plugins/rspec/examples/pure/shared_stack_examples.rb
pictrails-0.5.0 vendor/plugins/rspec/examples/pure/shared_stack_examples.rb
radiant-0.6.5.1 vendor/plugins/rspec/examples/pure/shared_stack_examples.rb