[ next ] [ prev ] [ contents ] XP-Cinti TDD Workshop

Untying the Knot

Our story requires that we have an untie method as well. First we write the test.

# file: testnet.rb
...
  def test_untie
    net = Net.new
    net.tie(1,1)
    net.untie(1,1)
    assert_equal true, net.untied?(1,1)
  end
...

And the implementation is straightforward ...

# file: net.rb
...
  def untie(x,y)
    @tied[x][y] = false
  end
...

And the tests say ...

  
$ ruby testnet.rb
Loaded suite testnet
Started...
.....
Finished in 0.044668 seconds.
4 runs, 7 assertions, 0 failures, 0 errors


[ next ] [ prev ] [ contents ] Copyright 2003 by Jim Weirich.
Some Rights Reserved