开发者

Equality using OR in RSpec 2

开发者 https://www.devze.com 2023-03-15 19:15 出处:网络
Wh开发者_C百科at is the correct way to write the following example? The player\'s score should equal 5 or 8.

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

精彩评论

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