开发者

Equality using OR in RSpec 2

Wh开发者_C百科at is the correct way to write the following example? The player's score should equal 5 or 8.

it "should equal 5 or 8" do
  player.score.should == 5 or 8
end

Thanks!

Tim


5 or 8 will produce result 5 all the time and not do what you expect. You can use Rspec's satisfy matcher.

 player.score.should satisfy {|s| [5,8].include?(s)}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜