繁体   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