Skip to content

Instantly share code, notes, and snippets.

@jszmajda
Created September 28, 2012 17:00
Show Gist options
  • Save jszmajda/3800974 to your computer and use it in GitHub Desktop.
Save jszmajda/3800974 to your computer and use it in GitHub Desktop.
Evil ping-pong pairing is fun
describe World do
it "should return no cell on a new board" do
w = World.new
w.cell_at(2,2).should be_nil
end
it "should allow cell creation" do
w = World.new
w.make_cell(2,2)
w.cell_at(2,2).should be_kind_of(Cell)
end
end
class World
def initialize
@calls =0
end
def cell_at(x,y)
return nil if @calls == 0
Cell.new
end
def make_cell(x,y)
@calls += 1
Cell.new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment