-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Random.raw_seed was renamed to Random.urandom
- Loading branch information
Showing
3 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,9 @@ | ||
# -*- encoding: binary -*- | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../shared/urandom', __FILE__) | ||
|
||
ruby_version_is "2.3" do | ||
describe "Random.raw_seed" do | ||
it "returns a String" do | ||
Random.raw_seed(1).should be_an_instance_of(String) | ||
end | ||
|
||
it "returns a String of the length given as argument" do | ||
Random.raw_seed(15).length.should == 15 | ||
end | ||
|
||
it "raises an ArgumentError on a negative size" do | ||
lambda { | ||
Random.raw_seed(-1) | ||
}.should raise_error(ArgumentError) | ||
end | ||
|
||
it "returns an ASCII-8BIT String" do | ||
Random.raw_seed(15).encoding.should == Encoding::ASCII_8BIT | ||
end | ||
|
||
it "returns a random binary String" do | ||
Random.raw_seed(12).should_not == Random.raw_seed(12) | ||
end | ||
ruby_version_is "2.5" do | ||
describe "Random.urandom" do | ||
it_behaves_like :random_urandom, :urandom | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
describe :random_urandom, shared: true do | ||
it "returns a String" do | ||
Random.send(@method, 1).should be_an_instance_of(String) | ||
end | ||
|
||
it "returns a String of the length given as argument" do | ||
Random.send(@method, 15).length.should == 15 | ||
end | ||
|
||
it "raises an ArgumentError on a negative size" do | ||
lambda { | ||
Random.send(@method, -1) | ||
}.should raise_error(ArgumentError) | ||
end | ||
|
||
it "returns an ASCII-8BIT String" do | ||
Random.send(@method, 15).encoding.should == Encoding::ASCII_8BIT | ||
end | ||
|
||
it "returns a random binary String" do | ||
Random.send(@method, 12).should_not == Random.send(@method, 12) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- encoding: binary -*- | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../shared/urandom', __FILE__) | ||
|
||
ruby_version_is "2.3"..."2.5" do | ||
describe "Random.raw_seed" do | ||
it_behaves_like :random_urandom, :raw_seed | ||
end | ||
end |