diff options
| author | Luc Donnet | 2017-10-16 23:52:06 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-10-16 23:52:06 +0200 |
| commit | f480ad0739e5c0ec2c0c8bb890344b9c4777ba35 (patch) | |
| tree | a19bc6b43449b8b978a53c33476fb3eb571d4dda /spec/support/random.rb | |
| parent | b611a84ed724036c4929bd4c3eaa7e23ea314f45 (diff) | |
| parent | 51a1ea5b141032121913f807a162d305828bec54 (diff) | |
| download | chouette-core-f480ad0739e5c0ec2c0c8bb890344b9c4777ba35.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'spec/support/random.rb')
| -rw-r--r-- | spec/support/random.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/support/random.rb b/spec/support/random.rb new file mode 100644 index 000000000..59e1a1475 --- /dev/null +++ b/spec/support/random.rb @@ -0,0 +1,30 @@ +module Support + module Random + + PRETTY_LARGE_INT = 1 << 30 + + def random_hex + SecureRandom.hex + end + + def random_element from + from[random_int(from.size)] + end + + def random_int max_plus_one=PRETTY_LARGE_INT + (random_number * max_plus_one).to_i + end + + def random_number + SecureRandom.random_number + end + + def random_string + SecureRandom.urlsafe_base64 + end + end +end + +RSpec.configure do | c | + c.include Support::Random +end |
