[Rspec-users] comments on my first context

Dominique Plante dominique.plante at gmail.com
Sat Jul 29 04:51:48 EDT 2006


I have been curious about rSpec for a while, so I thought I'd give it a try...

I started reading Ron Jeffries' articles on Sudoku
(http://www.xprogramming.com/xpmag/OkSudoku.htm), and noticed he was
doing TDD, I thought, this would be fun to do with BDD...

Can you comment on the following? (note that I added a method in the
Game class called cells which return @cells) to make the first spec
work)

Thanks!
Dominique

----------------------------------------------------------

# Inspired by:
# http://www.xprogramming.com/xpmag/OkSudoku.htm
# http://rspec.rubyforge.org/

require 'Game'

context "An Empty Board" do
  setup do
    @game = Game.test_game
  end

  specify "should have 81 cells" do
    @game.should.have(81).cells
  end

  specify "should have 0..80 in the cells" do
    (0..80).each do | i |
      @game.cell(i).should.equal i
    end
  end

  specify "check values in row 3" do
    @game.row(3).should.equal [27, 28, 29, 30, 31, 32, 33, 34, 35]
  end

  specify "check values in row 8" do
    @game.row(8).should.equal [72, 73, 74, 75, 76, 77, 78, 79, 80]
  end

  specify "check values in column 3" do
    @game.column(3).should.equal [3, 12, 21, 30, 39, 48, 57, 66, 75]
  end

  specify "check values in square 4 (middle square, counting from 0)" do
    @game.square(4).should.equal [30, 31, 32, 39, 40, 41, 48, 49, 50]
  end

  specify "check values in square 8 (last square, counting from 0)" do
    @game.square(8).should.equal [60, 61, 62, 69, 70, 71, 78, 79, 80]
  end

end
-------------------------------------------------------------
dom.website = http://www.binaryshift.com


More information about the Rspec-users mailing list