From 07a97b4b5d8db955514714db38332a64e2c789c6 Mon Sep 17 00:00:00 2001 From: Steve Richert Date: Fri, 12 Apr 2024 20:36:17 +0000 Subject: [PATCH] Complain if SecureRandom ever stops using Random::Formatter --- spec/secure_random_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/secure_random_spec.rb b/spec/secure_random_spec.rb index e2cc21c..b472d37 100644 --- a/spec/secure_random_spec.rb +++ b/spec/secure_random_spec.rb @@ -5,7 +5,11 @@ RSpec.describe SecureRandom do # Random::Formatter is responsible for decorating SecureRandom with all of # its public API methods, such as random_number, hex, uuid, etc. - Random::Formatter.public_instance_methods.sort.each do |method| + secure_random_methods = Random::Formatter.public_instance_methods + + raise "No public instance methods found on Random::Formatter" if secure_random_methods.none? + + secure_random_methods.sort.each do |method| describe ".#{method}" do it "is random and repeatable when enabled" do InsecureRandom.enable!