簡體   English   中英

rspec-參數數目錯誤(1..2為0)

[英]rspec - wrong number of arguments (0 for 1..2)

給出以下代碼:

class Game

  def self.game_board
    return [[][][]]
  end
  def self.empty_output
    '_|_|_'+
    '_|_|_'+
    ' | |'
  end
end

和這些測試:

describe 'It should display a grid' do
  it 'should have empty output' do
    Game.empty_output.should ==
    '_|_|_'+
    '_|_|_'+
    ' | |'
  end
  it 'should have an empty array for the game ' do
    Game.game_board.should ==
    [[][][]]
  end
end

為什么測試失敗,嘗試返回帶有錯誤的數組

.F

Failures:

  1) "It should display a grid should be empty
     Failure/Error: return [[][][]]
     ArgumentError:
       wrong number of arguments (0 for 1..2)
     # ./checkers_rspec.rb:4:in `[]'
     # ./checkers_rspec.rb:4:in `game_board'
     # ./checkers_rspec.rb:24:in `block (2 levels) in <top (required)>'

Finished in 0.00121 seconds
2 examples, 1 failure
[[][][]] should hae been [[],[],[]] in both cases.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM