此测试检查由generate_game
方法创建的井字棋盘是否确实具有三个每个三个值的子阵列。但是,我可以在一行中表达这一点,例如我在注释行中尝试做过吗?
it "should have three rows of three squares each" do
# expect([[_,_,_], [_,_,_], [_,_,_]] === generate_game).to_be true
game = generate_game
expect(game.length).to eq(3)
0.upto(2) do |num|
expect(game[num].length).to eq(3)
end
end