Ruby 随机数期望

Ruby 随机数期望,ruby,rspec,Ruby,Rspec,我对RSPEC和Ruby非常陌生,如果数字在0到36之间,如何创建一个通过的测试 提前谢谢 describe "Roulette" do context "Randomiser:" do it 'randomises a number between 0 and 36' expect(randomiser).to eq XXXX end end end 很简单 expect(randomiser).to be > 0

我对RSPEC和Ruby非常陌生,如果数字在0到36之间,如何创建一个通过的测试

提前谢谢

describe "Roulette" do
    context "Randomiser:" do
        it 'randomises a number between 0 and 36'
            expect(randomiser).to eq XXXX
        end
    end
end
很简单

expect(randomiser).to be > 0 
expect(randomiser).to be < 36
expect(randomiser).to>0
期望(随机化者)<36

randomiser.com应该大于0
随机化因子应小于36

干杯,亨伯

由于轮盘赌轮包括36和一个门牌号,这里有一个人为的例子:

describe "Roulette" do
  it 'randomizes a number between 0 and 36' do
    num = Random.new
    r_num = num.rand(36)
    r_num.should be >= 0
    r_num.should be <= 36
  end
end
描述“轮盘赌”是什么
它“将0到36之间的数字随机化”
num=Random.new
r_num=num.rand(36)
r_num.应大于等于0
r_num.应该是
describe "Roulette" do
  it 'randomizes a number between 0 and 36' do
    num = Random.new
    r_num = num.rand(36)
    r_num.should be >= 0
    r_num.should be <= 36
  end
end