0
votes

I am very new to RSPEC and Ruby How do I create a test that will pass if the number is between 0 and 36?

Thanks in advance.

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

2 Answers

0
votes

It's simple.

expect(randomiser).to be > 0 
expect(randomiser).to be < 36

or

randomiser.should be > 0
randomiser.should be < 36 

Cheers, humbroll.

0
votes

Since roulette wheels include 36 and a house number, here's a contrived example:

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