jeudi 1 décembre 2016

minitest getting nil and fail but method return correct anwser

I have the following test:

#!/usr/bin/env ruby
gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require_relative 'pawn'

class PawnTest < Minitest::Test
  def test_pawn_movement
    pawn = Pawn.new(1, 2, "N")
    pawn.move('LM'.split(''))
    result = pawn.display_final_position
    assert_equal '0 2 W', result
  end
end

This is the result of the test:

ruby rover_test.rb
Run options: --seed 9667

# Running:

0 2 W
F

Finished in 0.001743s, 573.7649 runs/s, 573.7649 assertions/s.

  1) Failure:
RoverTest#test_rover_movement [rover_test.rb:11]:
Expected: "0 2 W"
  Actual: nil

1 runs, 1 assertions, 1 failures, 0 errors, 0 skips

as you can see my test fail because expected was "0 2 W" but minimailer it's getting nil, but check the trace I'm really getting "0 2 W". What is the problem here.

Thanks in advance for your help.

Aucun commentaire:

Enregistrer un commentaire