Sha256: d06c773131ae689f053090465b84e9d4b92312e9049ccba0f33243bdebf51ef2

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

#---
# Excerpted from "Scripted GUI Testing With Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material, 
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
#---
require 'calculator'

describe 'a new calculator', :shared => true do
  before do
    @calc = Calculator.single
    @calc.clear
  end
end

module AdditionHelper
  def add_and_check(number, result)
    @calc.enter_number number
    @calc.equals
    @calc.total_seconds.should == result
  end
end


describe 'Starting with 1' do
  include AdditionHelper
  
  it_should_behave_like 'a new calculator'
  
  before do
    @calc.enter_number 1
    @calc.plus
  end

  it 'should add 0 correctly' do
    add_and_check(0, 1)
  end
  
  it 'should add 1 correctly' do
    add_and_check(1, 2)
  end
  
  # two more nearly-identical examples
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
win_gui-0.1.6 book_code/tables/calculator_spec.rb
win_gui-0.1.4 book_code/tables/calculator_spec.rb
win_gui-0.1.3 book_code/tables/calculator_spec.rb
win_gui-0.1.2 book_code/tables/calculator_spec.rb
win_gui-0.1.1 book_code/tables/calculator_spec.rb
win_gui-0.1.0 book_code/tables/calculator_spec.rb