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.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/spec/ruby/core/random/urandom_spec.rb b/spec/ruby/core/random/urandom_spec.rb
index e27f83cdcd..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_relative '../../spec_helper'
-require_relative 'shared/urandom'
-ruby_version_is ""..."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