What 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)}
来源:https://stackoverflow.com/questions/6474726/equality-using-or-in-rspec-2