Sha256: 4502a50326094ba7dfac137eec36b97a1d96ed5ae09017c97f60771af1600dc1

Contents?: true

Size: 1.48 KB

Versions: 54

Compression:

Stored size: 1.48 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'
require File.dirname(__FILE__) + "/stack"
require File.dirname(__FILE__) + '/shared_stack_examples'

describe Stack, " (empty)" do
  before(:each) do
    @stack = Stack.new
  end
  
  # NOTE that this one auto-generates the description "should be empty"
  it { @stack.should be_empty }
  
  it_should_behave_like "non-full Stack"
  
  it "should complain when sent #peek" do
    lambda { @stack.peek }.should raise_error(StackUnderflowError)
  end
  
  it "should complain when sent #pop" do
    lambda { @stack.pop }.should raise_error(StackUnderflowError)
  end
end

describe Stack, " (with one item)" do
  before(:each) do
    @stack = Stack.new
    @stack.push 3
    @last_item_added = 3
  end

  it_should_behave_like "non-empty Stack"
  it_should_behave_like "non-full Stack"

end

describe Stack, " (with one item less than capacity)" do
  before(:each) do
    @stack = Stack.new
    (1..9).each { |i| @stack.push i }
    @last_item_added = 9
  end
  
  it_should_behave_like "non-empty Stack"
  it_should_behave_like "non-full Stack"
end

describe Stack, " (full)" do
  before(:each) do
    @stack = Stack.new
    (1..10).each { |i| @stack.push i }
    @last_item_added = 10
  end

  # NOTE that this one auto-generates the description "should be full"
  it { @stack.should be_full }  

  it_should_behave_like "non-empty Stack"

  it "should complain on #push" do
    lambda { @stack.push Object.new }.should raise_error(StackOverflowError)
  end
  
end

Version data entries

54 entries across 54 versions & 9 rubygems

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