rspec_random 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/rspec_random.rb +37 -0
  2. metadata +45 -0
@@ -0,0 +1,37 @@
1
+ def random_email
2
+ "#{random_text}@#{random_text}.com".downcase
3
+ end
4
+
5
+ def random_text(options={})
6
+ length = if options[:length]
7
+ options[:length]
8
+ elsif options[:max_length]
9
+ 1 + rand(options[:max_length])
10
+ else
11
+ 1 + rand(32)
12
+ end
13
+
14
+ chars = ("A".."Z").to_a + ("a".."z").to_a + ("0".."9").to_a
15
+
16
+ (1..length).map { chars.sample }.join("")
17
+ end
18
+
19
+ def random_time
20
+ Time.at rand Time.now.to_i
21
+ end
22
+
23
+ def random_url
24
+ tld = ["com", "org", "net", "biz", "info", "co", "co.in"].sample
25
+ domain = (0..rand(3)).map { random_text.downcase }.join(".")
26
+ scheme = ["http", "https"].sample
27
+
28
+ "#{scheme}://#{domain}.#{tld}"
29
+ end
30
+
31
+ def random_exception
32
+ begin
33
+ raise random_string
34
+ rescue => e
35
+ e
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec_random
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sujoy Gupta
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-08 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description:
15
+ email: sujoyg@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/rspec_random.rb
21
+ homepage: http://github.com/sujoyg/rspec_random
22
+ licenses: []
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 1.8.24
42
+ signing_key:
43
+ specification_version: 3
44
+ summary: RSpec helpers for generating random entities.
45
+ test_files: []