spec/extensions/range_spec.rb in forgery-0.6.0 vs spec/extensions/range_spec.rb in forgery-0.7.0
- old
+ new
@@ -1,31 +1,33 @@
require 'spec_helper'
require 'timeout'
describe Range do
- it "should get a random number out of the range" do
+ it 'should get a random number out of the range' do
range = Forgery::Extend(0..9)
- 10.times { range.should include(range.random) }
+ 10.times { expect(range).to include(range.random) }
end
- it "should not take a long time when the range is huge" do
- Timeout.timeout(1){Forgery::Extend(1234567890..12345678901234567890).random}.should_not raise_error(Timeout::Error)
+ it 'should not take a long time when the range is huge' do
+ expect do
+ Timeout.timeout(1) { Forgery::Extend(1_234_567_890..12_345_678_901_234_567_890).random }
+ end.not_to raise_error
end
- it "should return nil for a random number from a reverse range" do
- 10.times { Forgery::Extend(9..0).random.should be_nil }
+ it 'should return nil for a random number from a reverse range' do
+ 10.times { expect(Forgery::Extend(9..0).random).to be_nil }
end
- it "should get a random string our of the range" do
- range = Forgery::Extend("a".."z")
- 10.times { range.should include(range.random) }
+ it 'should get a random string our of the range' do
+ range = Forgery::Extend('a'..'z')
+ 10.times { expect(range).to include(range.random) }
end
- it "should return nil if the maximum is less than the minimum" do
- Forgery::Extend("z".."a").random.should be_nil
+ it 'should return nil if the maximum is less than the minimum' do
+ expect(Forgery::Extend('z'..'a').random).to be_nil
end
- it "should not return the maximum at excluded range" do
- Kernel.should_receive(:rand).with(9).and_return(8)
- Forgery::Extend(0...9).random.should_not be_equal 9
+ it 'should not return the maximum at excluded range' do
+ expect(Random).to receive(:rand).with(0...9).and_return(8)
+ expect(Forgery::Extend(0...9).random).to_not eq(9)
end
end