相关疑难解决方法(0)

使用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 
Run Code Online (Sandbox Code Playgroud)

我知道,这是冗长的.是否有更简洁的方式来陈述我的期望.我看过文档,但我看不出在哪里压缩我的期望.谢谢.

ruby rspec expectations

54
推荐指数
4
解决办法
4万
查看次数

标签 统计

expectations ×1

rspec ×1

ruby ×1