summaryrefslogtreecommitdiff
path: root/spec/ruby/core/random/urandom_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/random/urandom_spec.rb')
-rw-r--r--spec/ruby/core/random/urandom_spec.rb28
1 files changed, 22 insertions, 6 deletions
diff --git a/spec/ruby/core/random/urandom_spec.rb b/spec/ruby/core/random/urandom_spec.rb
index 1cc0103e35..94e9423a06 100644
--- a/spec/ruby/core/random/urandom_spec.rb
+++ b/spec/ruby/core/random/urandom_spec.rb
@@ -1,9 +1,25 @@
-# -*- encoding: binary -*-
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/urandom', __FILE__)
+require_relative '../../spec_helper'
-ruby_version_is "2.3"..."2.5" do
- describe "Random.raw_seed" do
- it_behaves_like :random_urandom, :raw_seed
+describe "Random.urandom" do
+ it "returns a String" do
+ Random.urandom(1).should.instance_of?(String)
+ end
+
+ it "returns a String of the length given as argument" do
+ Random.urandom(15).length.should == 15
+ end
+
+ it "raises an ArgumentError on a negative size" do
+ -> {
+ Random.urandom(-1)
+ }.should.raise(ArgumentError)
+ end
+
+ it "returns a binary String" do
+ Random.urandom(15).encoding.should == Encoding::BINARY
+ end
+
+ it "returns a random binary String" do
+ Random.urandom(12).should_not == Random.urandom(12)
end
end