Skip to content

Commit a9c0577

Browse files
authored
Merge pull request #2690 from ksss/securerandom-bytes
Add signature for `SecureRandom.bytes`
2 parents 4482ed2 + 4fdd4c3 commit a9c0577

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

stdlib/securerandom/0/securerandom.rbs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,15 @@
3535
# raised.
3636
#
3737
module SecureRandom
38+
# <!--
39+
# rdoc-file=lib/securerandom.rb
40+
# - bytes(n)
41+
# -->
42+
# Returns a random binary string containing `size` bytes.
43+
#
44+
# See Random.bytes
45+
#
46+
def self.bytes: (Integer) -> String
47+
3848
extend Random::Formatter
3949
end

test/stdlib/SecureRandom_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ class SecureRandomSingletonTest < Test::Unit::TestCase
77
library "securerandom"
88
testing "singleton(::SecureRandom)"
99

10+
def test_bytes
11+
assert_send_type "(::Integer) -> ::String",
12+
SecureRandom, :bytes, 10
13+
end
14+
1015
def test_uuid
1116
assert_send_type "() -> ::String",
1217
SecureRandom, :uuid

0 commit comments

Comments
 (0)