4
 assert_nothing_raised do
   @board.make_move(0,0,Board::HUMAN)
 end

and the docs say:

Passes if block does not throw anything.

Example:

 assert_nothing_thrown do
   [1, 2].uniq
 end

my make_move method:

def make_move(x, y, player)
    return false
 end

I get the error:

test_can_make_valid_move_in_the_first_row(BoardTest):
ArgumentError: wrong number of arguments (1 for 2)
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
  • What testing framework are you using? Ruby's own unit/test? [minitest](https://github.com/seattlerb/minitest)? Something else? – Phrogz Jan 30 '11 at 16:18

2 Answers2

4

This following code works for me. Does it work for you?

require 'test/unit'
require 'test/unit/ui/console/testrunner'

class MyTestClass < Test::Unit::TestCase
  def test_something
    assert_nothing_raised do
      p 'hi'
    end
  end
end

Test::Unit::UI::Console::TestRunner.run(MyTestClass)

I think you are using assert_nothing_raised correctly. Try replacing

@board.make_move(0,0,Board::HUMAN)

with something more simple, like

p 'hi'

and see if that works. Also try commenting out all the other code in your test.

Mike A.
  • 3,189
  • 22
  • 20
3

It can be argued that you should never use assert_nothing_raised, as it does not actually test anything. See:

http://blog.zenspider.com/blog/2012/01/assert_nothing_tested.html

I've posted some further thoughts here:

Why doesn't MiniTest::Spec have a wont_raise assertion?

Community
  • 1
  • 1
matt
  • 515,959
  • 87
  • 875
  • 1,141