describe 'rand' do # fails: it "should be mockable (rand)" do Kernel.should_receive(:rand).and_return('foo') rand() end # passes: it "should be mockable (Kernel.rand)" do Kernel.should_receive(:rand).and_return('foo') Kernel.rand() end end