Tôi có một bài kiểm tra như sau:Testing băm nội dung sử dụng 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
đó, tôi biết, là tiết. Có cách nào ngắn gọn hơn để nêu ra kỳ vọng của tôi không. Tôi đã xem xét các tài liệu nhưng tôi không thể nhìn thấy nơi để nén mong đợi của tôi. Cảm ơn.
Cảm ơn, David. Quạt lớn BTW. Thực sự rất thích cuốn sách RSpec. –
Tôi ước có một phương pháp tương ứng như match_array –
Ditto trên Fanage David! "Cuốn sách Rspec" của bạn là tốt! –