測試哈希內容我有一個測試,像這樣:使用RSpec的
it "should not indicate backwards jumps if the checker position is not a king" do
board = Board.new
game_board = board.create_test_board
board.add_checker(game_board, :red, 3, 3)
x_coord = 3
y_coord = 3
jump_locations = {}
jump_locations["upper_left"] = true
jump_locations["upper_right"] = false
jump_locations["lower_left"] = false
jump_locations["lower_right"] = true
adjusted_jump_locations = @bs.adjust_jump_locations_if_not_king(game_board, x_coord, y_coord, jump_locations)
adjusted_jump_locations["upper_left"].should == true
adjusted_jump_locations["upper_right"].should == false
adjusted_jump_locations["lower_left"].should == false
adjusted_jump_locations["lower_right"].should == false
end
它,我知道,很冗長。是否有更簡明的方式來陳述我的期望?我查看了文檔,但我無法看到壓縮我的期望的地方。謝謝。
謝謝你,大衛。順便說一句巨大的粉絲。真的很喜歡RSpec書。 –
我希望有一個像match_array相應的方法 –
在Fanage David上同上!你的「Rspec書」已經很好了! –