pseudo_entity 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/pseudo_entity/randoms/location.rb +4 -5
- data/lib/pseudo_entity/version.rb +1 -1
- metadata +49 -56
- data/.gitignore +0 -20
- data/pseudo_entity.gemspec +0 -31
- data/spec/lib/pseudo_entity/randoms_spec.rb +0 -287
- data/spec/lib/pseudo_entity_spec.rb +0 -172
- data/spec/spec_helper.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 67f8a85e3fe08c09eda5f3100bdc882689afde2c456d9b4ce40689f9da6ddcdb
|
4
|
+
data.tar.gz: d40a2dae8ab2fdc9c3fe0128e5fbc4f545a0a25de1addc7ca39bd889da1cbb34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46f26e2311b6b91d71acf023eedd9cecaf873beabdce1a4f6ed0788e43944e0041702dcbfd0678642d745d185776d7bb39b5b2ba208a7bcf657aac04b02addf
|
7
|
+
data.tar.gz: 1de9d7a489007fd015f0ac28de120ecf190ceced78d152e55b32561d3b3fed86ca3680d4d4e199acd32cb7341bccc4dd95a0e7e7ab68b19055879ef3d98cca31
|
@@ -19,12 +19,11 @@ class PseudoEntity::Randoms::Location
|
|
19
19
|
@latitude = options[:latitude].to_f
|
20
20
|
@longitude = options[:longitude].to_f
|
21
21
|
@country_code = options[:country_code]
|
22
|
-
time_zone = options[:time_zone]
|
23
|
-
unless time_zone.is_a?(ActiveSupport::TimeZone)
|
24
|
-
|
25
|
-
time_zone =
|
22
|
+
@time_zone = options[:time_zone]
|
23
|
+
unless @time_zone.is_a?(ActiveSupport::TimeZone)
|
24
|
+
tzinfo = ActiveSupport::TimeZone.find_tzinfo(@time_zone.to_s.sub(/^\(.*?\) /, '')) rescue nil
|
25
|
+
@time_zone = tzinfo && ActiveSupport::TimeZone.all.find { |x| x.tzinfo == tzinfo } || idealized_time_zone
|
26
26
|
end
|
27
|
-
@time_zone = time_zone
|
28
27
|
end
|
29
28
|
|
30
29
|
def to_s
|
metadata
CHANGED
@@ -1,127 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudo_entity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Hall
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: uuidtools
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2.
|
61
|
+
version: '2.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '2.
|
68
|
+
version: '2.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '7'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: tzinfo
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: tzinfo
|
98
|
+
name: tzinfo-data
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: huge_enumerable
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
117
|
+
version: '0.1'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
124
|
+
version: '0.1'
|
125
125
|
description: A class for generating realistic looking data for people, companies,
|
126
126
|
etc.
|
127
127
|
email:
|
@@ -130,7 +130,6 @@ executables: []
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
-
- .gitignore
|
134
133
|
- Gemfile
|
135
134
|
- LICENSE.txt
|
136
135
|
- README.md
|
@@ -142,35 +141,29 @@ files:
|
|
142
141
|
- lib/pseudo_entity/randoms/locations_hash.rb
|
143
142
|
- lib/pseudo_entity/randoms/zip_code_database.csv
|
144
143
|
- lib/pseudo_entity/version.rb
|
145
|
-
|
146
|
-
- spec/lib/pseudo_entity/randoms_spec.rb
|
147
|
-
- spec/lib/pseudo_entity_spec.rb
|
148
|
-
- spec/spec_helper.rb
|
149
|
-
homepage: http://chapterhouse.github.io/pseudo_entity
|
144
|
+
homepage: https://github.com/ChapterHouse/pseudo_entity
|
150
145
|
licenses:
|
151
146
|
- MIT
|
152
|
-
metadata:
|
153
|
-
|
147
|
+
metadata:
|
148
|
+
homepage_uri: https://github.com/ChapterHouse/pseudo_entity
|
149
|
+
source_code_uri: https://github.com/ChapterHouse/pseudo_entity/tree/v0.1.0
|
150
|
+
post_install_message:
|
154
151
|
rdoc_options: []
|
155
152
|
require_paths:
|
156
153
|
- lib
|
157
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
158
155
|
requirements:
|
159
|
-
- -
|
156
|
+
- - ">="
|
160
157
|
- !ruby/object:Gem::Version
|
161
|
-
version: '0'
|
158
|
+
version: '3.0'
|
162
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
160
|
requirements:
|
164
|
-
- -
|
161
|
+
- - ">="
|
165
162
|
- !ruby/object:Gem::Version
|
166
163
|
version: '0'
|
167
164
|
requirements: []
|
168
|
-
|
169
|
-
|
170
|
-
signing_key:
|
165
|
+
rubygems_version: 3.2.32
|
166
|
+
signing_key:
|
171
167
|
specification_version: 4
|
172
168
|
summary: A class for generating realistic looking data for people, companies, etc.
|
173
|
-
test_files:
|
174
|
-
- spec/lib/pseudo_entity/randoms_spec.rb
|
175
|
-
- spec/lib/pseudo_entity_spec.rb
|
176
|
-
- spec/spec_helper.rb
|
169
|
+
test_files: []
|
data/.gitignore
DELETED
data/pseudo_entity.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'pseudo_entity/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'pseudo_entity'
|
8
|
-
spec.version = PseudoEntity::VERSION
|
9
|
-
spec.authors = ['Frank Hall']
|
10
|
-
spec.email = ['ChapterHouse.Dune@gmail.com']
|
11
|
-
spec.description = %q{A class for generating realistic looking data for people, companies, etc.}
|
12
|
-
spec.summary = %q{A class for generating realistic looking data for people, companies, etc.}
|
13
|
-
spec.homepage = 'http://chapterhouse.github.io/pseudo_entity'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
-
spec.add_development_dependency 'rake'
|
23
|
-
spec.add_development_dependency 'rspec', '~> 2.13'
|
24
|
-
|
25
|
-
spec.add_runtime_dependency 'uuidtools', '~> 2.1'
|
26
|
-
spec.add_runtime_dependency 'activesupport', '>= 2.0'
|
27
|
-
spec.add_runtime_dependency 'iconv' # This is here only while I support activesupport < 3 which is about as long as I support ruby 1.8.7
|
28
|
-
spec.add_runtime_dependency 'tzinfo'
|
29
|
-
spec.add_runtime_dependency 'huge_enumerable'
|
30
|
-
|
31
|
-
end
|
@@ -1,287 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PseudoEntity::Randoms do
|
4
|
-
|
5
|
-
RSpec::Matchers.define :be_all_digits do
|
6
|
-
match do |string|
|
7
|
-
string.gsub(/[0-9]*/,'').empty?
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec::Matchers.define :be_all_alphabetic_characters do
|
12
|
-
match do |string|
|
13
|
-
string.gsub(/[a-z]|[A-Z]*/,'').empty?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
RSpec::Matchers.define :be_all_alphanumeric_characters do
|
18
|
-
match do |string|
|
19
|
-
string.gsub(/[a-z]|[A-Z][0-9]*/,'').empty?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
context "when included" do
|
25
|
-
|
26
|
-
let(:class_a_regex) { /^10\.(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){2}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ }
|
27
|
-
let(:class_b_regex) { /^172\.(?:(?:1[6-9]|2[0-9]|3[0-1]?)\.)(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.)(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ }
|
28
|
-
let(:class_c_regex) { /^192\.168\.(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.)(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ }
|
29
|
-
|
30
|
-
subject(:instance) do
|
31
|
-
klass = Class.new
|
32
|
-
klass.send(:include, PseudoEntity::Randoms)
|
33
|
-
klass.new
|
34
|
-
end
|
35
|
-
|
36
|
-
it "responds to all RandomValues" do
|
37
|
-
PseudoEntity::RandomValues.all? { |method| instance.respond_to?(method.to_sym) }.should be_true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "lists all RandomValues as methods" do
|
41
|
-
(PseudoEntity::RandomValues.map(&:to_s) - instance.methods.map(&:to_s)).should be_empty
|
42
|
-
end
|
43
|
-
|
44
|
-
it "responds to ArityValues" do
|
45
|
-
methods = PseudoEntity::ArityValues.map { |regexp| regexp.to_s.match(/.*\^(.*_)\\d.*/)[1] + rand(100).to_s }
|
46
|
-
methods.all? { |method| instance.respond_to?(method.to_sym) }.should be_true
|
47
|
-
end
|
48
|
-
|
49
|
-
it "responds to ArityRandoms" do
|
50
|
-
methods = PseudoEntity::ArityRandoms.map { |regexp| regexp.to_s.match(/.*\^(.*_)\\d.*/)[1] + rand(100).to_s }
|
51
|
-
methods.all? { |method| instance.respond_to?(method.to_sym, true) }.should be_true
|
52
|
-
end
|
53
|
-
|
54
|
-
it "has private ArityRandoms" do
|
55
|
-
methods = PseudoEntity::ArityRandoms.map { |regexp| regexp.to_s.match(/.*\^(.*_)\\d.*/)[1] + rand(100).to_s }
|
56
|
-
methods.all? { |method| !instance.respond_to?(method.to_sym) }.should be_true
|
57
|
-
end
|
58
|
-
|
59
|
-
it "has corresponding private random_X methods for RandomValues" do
|
60
|
-
(PseudoEntity::RandomValues.map { |method| "random_#{method}".to_sym } - instance.private_methods.map(&:to_sym)).should be_empty
|
61
|
-
end
|
62
|
-
|
63
|
-
context "#parse_options" do
|
64
|
-
|
65
|
-
it "sets initial values" do
|
66
|
-
value_names = PseudoEntity::RandomValues
|
67
|
-
hash = value_names.inject({}) { |hsh, name| hsh[name] = "123 #{name}"; hsh}
|
68
|
-
instance.send(:parse_options, hash)
|
69
|
-
value_names.all? { |name| instance.send(name) == "123 #{name}" }.should be_true
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
context "#random_alpha" do
|
75
|
-
|
76
|
-
it "returns X characters" do
|
77
|
-
instance.send(:random_alpha, 256).size.should eql(256)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "only generates alphabetic characters" do
|
81
|
-
instance.stub(:rand).and_return(*(0..51).to_a)
|
82
|
-
instance.send(:random_alpha, 256).should be_all_alphanumeric_characters
|
83
|
-
# If only alphabetic characters are available then nothing should show up at slot 52
|
84
|
-
instance.stub(:rand).and_return(52)
|
85
|
-
instance.send(:random_alpha, 1).size.should eq(0)
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
context "#random_alpha_numeric" do
|
91
|
-
|
92
|
-
it "returns X characters" do
|
93
|
-
instance.send(:random_alpha_numeric, 256).size.should eql(256)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "only generates alphabetic characters or digits" do
|
97
|
-
instance.stub(:rand).and_return(*(0..61).to_a)
|
98
|
-
instance.send(:random_alpha, 256).should be_all_alphabetic_characters
|
99
|
-
# If only alphabetic characters and digits are available then nothing should show up at slot 62
|
100
|
-
instance.stub(:rand).and_return(62)
|
101
|
-
instance.send(:random_alpha_numeric, 1).size.should eq(0)
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
context "#random_apartment_number" do
|
107
|
-
|
108
|
-
it "never returns zero or less" do
|
109
|
-
instance.stub(:rand).and_return(0)
|
110
|
-
instance.send(:random_apartment_number).should > 0
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
context "#random_bank_account_number" do
|
116
|
-
|
117
|
-
it "is thirteen characters long" do
|
118
|
-
instance.send(:random_bank_account_number).size.should eql(13)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "is all digits" do
|
122
|
-
instance.send(:random_bank_account_number).should be_all_digits
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
context "#random_bank_routing_number" do
|
128
|
-
|
129
|
-
it "is nine characters long" do
|
130
|
-
instance.send(:random_bank_routing_number).size.should eql(9)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "is all digits" do
|
134
|
-
instance.send(:random_bank_routing_number).should be_all_digits
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
context "#random_numeric" do
|
140
|
-
|
141
|
-
it "return X characters" do
|
142
|
-
instance.send(:random_alpha_numeric, 256).size.should eql(256)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "only generates digits" do
|
146
|
-
instance.send(:random_numeric, 256).should be_all_digits
|
147
|
-
end
|
148
|
-
|
149
|
-
end
|
150
|
-
|
151
|
-
context "#random_birth_day" do
|
152
|
-
|
153
|
-
it "is always be at least 21 years ago" do
|
154
|
-
instance.stub(:rand).and_return(0)
|
155
|
-
(Date.today.year - instance.send(:random_birth_day).year).should >= 21
|
156
|
-
end
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
context "#random_class_a_ip_address" do
|
161
|
-
|
162
|
-
it "is in the private class A range" do
|
163
|
-
instance.send(:random_class_a_ip_address).should =~ class_a_regex
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
context "#random_class_b_ip_address" do
|
169
|
-
|
170
|
-
it "is in the private class B range" do
|
171
|
-
instance.send(:random_class_b_ip_address).should =~ class_b_regex
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
context "#random_class_c_ip_address" do
|
177
|
-
|
178
|
-
it "is in the private class C range" do
|
179
|
-
instance.send(:random_class_c_ip_address).should =~ class_c_regex
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
context "#random_email_address" do
|
185
|
-
|
186
|
-
it "conforms to the pattern name@domain" do
|
187
|
-
simple_email_regex = /^.*@.*\..*$/
|
188
|
-
instance.send(:random_email_address) =~ simple_email_regex
|
189
|
-
end
|
190
|
-
|
191
|
-
end
|
192
|
-
|
193
|
-
context "#random_facebook_id" do
|
194
|
-
|
195
|
-
it "is all digits" do
|
196
|
-
instance.send(:random_facebook_id).should be_all_digits
|
197
|
-
end
|
198
|
-
|
199
|
-
it "is a maximum of 64 bits long" do
|
200
|
-
# This is a little brittle but not sure how else to test this
|
201
|
-
instance.should_receive(:rand).with(2**64).and_return(2**64)
|
202
|
-
instance.send(:random_facebook_id)
|
203
|
-
end
|
204
|
-
|
205
|
-
end
|
206
|
-
|
207
|
-
context "#random_federal_tax_id" do
|
208
|
-
|
209
|
-
it "is nine characters long" do
|
210
|
-
instance.send(:random_federal_tax_id).size.should eql(9)
|
211
|
-
end
|
212
|
-
|
213
|
-
it "is all digits" do
|
214
|
-
instance.send(:random_federal_tax_id).should be_all_digits
|
215
|
-
end
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
context "#random_google_analytics_account_id" do
|
220
|
-
it "conforms to Google's Analytic Account pattern" do
|
221
|
-
instance.send(:random_google_analytics_account_id).should =~ /^UA-\d{7}-\d{2}$/
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
context "#random_ip_address" do
|
226
|
-
|
227
|
-
it "is one of the non routable IP addresses" do
|
228
|
-
ip_address = instance.send(:random_ip_address)
|
229
|
-
[class_a_regex, class_b_regex, class_c_regex].any? { |regexp| ip_address =~ regexp }.should be_true
|
230
|
-
end
|
231
|
-
|
232
|
-
end
|
233
|
-
|
234
|
-
context "#random_phone_number" do
|
235
|
-
|
236
|
-
it "is a ten digit comma separated value" do
|
237
|
-
instance.send(:random_phone_number).should =~ /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/
|
238
|
-
end
|
239
|
-
|
240
|
-
end
|
241
|
-
|
242
|
-
context "#random_property_number" do
|
243
|
-
|
244
|
-
it "will never be less than 10" do
|
245
|
-
instance.stub(:rand).and_return(0)
|
246
|
-
instance.send(:random_property_number).should >= 10
|
247
|
-
end
|
248
|
-
|
249
|
-
end
|
250
|
-
|
251
|
-
context "#random_sex" do
|
252
|
-
|
253
|
-
it "will never be less than 10" do
|
254
|
-
instance.stub(:rand).and_return(0)
|
255
|
-
instance.send(:random_property_number).should >= 10
|
256
|
-
end
|
257
|
-
|
258
|
-
end
|
259
|
-
|
260
|
-
context "#rand_X" do
|
261
|
-
|
262
|
-
it "generates a random number" do
|
263
|
-
Kernel.should_receive(:rand).with(10).once.and_call_original
|
264
|
-
first = instance.rand_10
|
265
|
-
second = instance.rand_10
|
266
|
-
first.should eql(second)
|
267
|
-
end
|
268
|
-
|
269
|
-
end
|
270
|
-
|
271
|
-
end
|
272
|
-
|
273
|
-
context "as itself" do
|
274
|
-
|
275
|
-
subject(:random) { PseudoEntity::Randoms }
|
276
|
-
|
277
|
-
it "creates a token smaller than 32 characters" do
|
278
|
-
random.token(3).size.should eq(3)
|
279
|
-
end
|
280
|
-
|
281
|
-
it "creates a token larger than 32 characters" do
|
282
|
-
random.token(128).size.should eq(128)
|
283
|
-
end
|
284
|
-
|
285
|
-
end
|
286
|
-
|
287
|
-
end
|
@@ -1,172 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PseudoEntity do
|
4
|
-
|
5
|
-
let(:age) { 10 }
|
6
|
-
let(:date) { age.years.ago }
|
7
|
-
let(:cc_last_four) { '4321' }
|
8
|
-
let(:latitude) { 1.2 }
|
9
|
-
let(:longitude) { 3.4 }
|
10
|
-
let(:street_position) { 'street_position' }
|
11
|
-
let(:company_name) { 'Some Company Ltd.'}
|
12
|
-
let(:city) { 'St. Archibald' }
|
13
|
-
let(:state) { 'ZZ' }
|
14
|
-
let(:zip_code) { 12345 }
|
15
|
-
let(:first_name) { 'John' }
|
16
|
-
let(:last_name) { 'Smith' }
|
17
|
-
|
18
|
-
subject(:pseudo_entity) do
|
19
|
-
PseudoEntity.new.tap{ |pe|
|
20
|
-
pe.stub(:birth_day).and_return(date)
|
21
|
-
pe.stub(:city).and_return(city)
|
22
|
-
pe.stub(:state).and_return(state)
|
23
|
-
pe.stub(:zip_code).and_return(zip_code)
|
24
|
-
pe.stub(:credit_card_number).and_return('98765' + cc_last_four)
|
25
|
-
pe.stub(:first_name).and_return(first_name)
|
26
|
-
pe.stub(:last_name).and_return(last_name)
|
27
|
-
pe.stub(:latitude).and_return(latitude)
|
28
|
-
pe.stub(:longitude).and_return(longitude)
|
29
|
-
pe.stub(:street_position).and_return(street_position)
|
30
|
-
pe.stub(:company_name).and_return(company_name)
|
31
|
-
pe.stub(:city).and_return(city)
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should calculate age" do
|
36
|
-
pseudo_entity.age.should eql(age)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should combine components into a full address" do
|
40
|
-
pseudo_entity.stub(:street_address).and_return('street_address')
|
41
|
-
pseudo_entity.address.should eql("street_address\n#{city}, #{state}. #{zip_code}")
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should identify when an address is and is not an apartment" do
|
45
|
-
pseudo_entity.stub(:street_modifier_needed).and_return(:apartment)
|
46
|
-
pseudo_entity.apartment?.should be_true
|
47
|
-
pseudo_entity.stub(:street_modifier_needed).and_return(:something_else)
|
48
|
-
pseudo_entity.apartment?.should be_false
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should extract birth year" do
|
52
|
-
pseudo_entity.birth_year.should eql(date.year)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should extract the last four digits of the credit card number" do
|
56
|
-
pseudo_entity.credit_card_last_four.should eql(cc_last_four)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should combine names into a full name" do
|
60
|
-
pseudo_entity.full_name.should eql("#{first_name} #{last_name}")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should generate a google map url from latitude and longitude" do
|
64
|
-
pseudo_entity.google_map_url.should eql("https://maps.google.com/maps?q=loc:#{latitude},#{longitude}")
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should not return new values without resetting" do
|
68
|
-
pseudo_entity = PseudoEntity.new
|
69
|
-
first_name = pseudo_entity.first_name
|
70
|
-
pseudo_entity.first_name.should equal(first_name)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should return new values after a reset" do
|
74
|
-
pseudo_entity = PseudoEntity.new
|
75
|
-
first_name = pseudo_entity.first_name
|
76
|
-
last_name = pseudo_entity.last_name
|
77
|
-
pseudo_entity.reset!
|
78
|
-
pseudo_entity.first_name.should_not eql(first_name)
|
79
|
-
pseudo_entity.last_name.should_not eql(last_name)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should return self after a reset" do
|
83
|
-
pseudo_entity.reset!.should equal(pseudo_entity)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should reset a single value" do
|
87
|
-
pseudo_entity = PseudoEntity.new
|
88
|
-
first_name = pseudo_entity.first_name
|
89
|
-
last_name = pseudo_entity.last_name
|
90
|
-
pseudo_entity.reset("first_name")
|
91
|
-
pseudo_entity.first_name.should_not eql(first_name)
|
92
|
-
pseudo_entity.last_name.should eql(last_name)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should return the new value after a reset of a single value" do
|
96
|
-
pseudo_entity = PseudoEntity.new
|
97
|
-
first_name_a = pseudo_entity.first_name
|
98
|
-
first_name_b = pseudo_entity.reset("first_name")
|
99
|
-
first_name_a.should_not eql(first_name_b)
|
100
|
-
first_name_b.should eql(pseudo_entity.first_name)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should combine addresses in 2,1 order" do
|
104
|
-
pseudo_entity.stub(:street_address_line_1).and_return(:street_address_line_1)
|
105
|
-
pseudo_entity.stub(:street_address_line_2).and_return(:street_address_line_2)
|
106
|
-
pseudo_entity.street_address.should eql('street_address_line_2 street_address_line_1')
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should trim missing street information" do
|
110
|
-
pseudo_entity.stub(:street_address_line_1).and_return(:street_address_line_1)
|
111
|
-
pseudo_entity.stub(:street_address_line_2).and_return('')
|
112
|
-
pseudo_entity.street_address.should == 'street_address_line_1'
|
113
|
-
pseudo_entity.stub(:street_address_line_1).and_return('')
|
114
|
-
pseudo_entity.stub(:street_address_line_2).and_return(:street_address_line_2)
|
115
|
-
pseudo_entity.street_address.should eql('street_address_line_2')
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should apartment number as street address line 1 when the address is at an apartment" do
|
119
|
-
apartment_number = 1234
|
120
|
-
pseudo_entity.stub(:apartment_number).and_return(apartment_number)
|
121
|
-
pseudo_entity.stub(:apartment?).and_return(true)
|
122
|
-
pseudo_entity.stub(:suite?).and_return(false)
|
123
|
-
pseudo_entity.street_address_line_1.should eql("APT #{apartment_number}")
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should suite number as street address line 1 when the address is at a suite" do
|
127
|
-
suite_number = 1234
|
128
|
-
pseudo_entity.stub(:suite_number).and_return(suite_number)
|
129
|
-
pseudo_entity.stub(:apartment?).and_return(false)
|
130
|
-
pseudo_entity.stub(:suite?).and_return(true)
|
131
|
-
pseudo_entity.street_address_line_1.should eql("STE #{suite_number}")
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should use the street position as street address line 1 when not at an apartment or suite" do
|
135
|
-
pseudo_entity.stub(:apartment?).and_return(false)
|
136
|
-
pseudo_entity.stub(:suite?).and_return(false)
|
137
|
-
pseudo_entity.street_address_line_1.should eql(street_position)
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should use street position as street address line 2 when a street modifier is needed" do
|
141
|
-
pseudo_entity.stub(:street_modifier_needed?).and_return(true)
|
142
|
-
pseudo_entity.street_address_line_2.should eql(street_position)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should return nil as street address line 2 when a street modifier is not needed" do
|
146
|
-
pseudo_entity.stub(:street_modifier_needed?).and_return(false)
|
147
|
-
pseudo_entity.street_address_line_2.should be_nil
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should identify when an address is and is not an suite" do
|
151
|
-
pseudo_entity.stub(:street_modifier_needed).and_return(:suite)
|
152
|
-
pseudo_entity.suite?.should be_true
|
153
|
-
pseudo_entity.stub(:street_modifier_needed).and_return(:something_else)
|
154
|
-
pseudo_entity.suite?.should be_false
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should generate a yelp business id from the company name and the city" do
|
158
|
-
pseudo_entity.yelp_business_id.should == 'Some-Company-Ltd-St-Archibald'
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should generate a yelp business url from the yelp business id" do
|
162
|
-
pseudo_entity.stub(:yelp_business_id).and_return(:yelp_business_id)
|
163
|
-
pseudo_entity.yelp_business_url.should == 'http://www.yelp.com/biz/yelp_business_id'
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should generate a string 22 characters long for yelp user id" do
|
167
|
-
yelp_user_id = pseudo_entity.yelp_user_id
|
168
|
-
yelp_user_id.should be_an_instance_of(String)
|
169
|
-
yelp_user_id.size.should eql(22)
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'pseudo_entity'
|