pseudo_entity 0.0.3 → 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 67f8a85e3fe08c09eda5f3100bdc882689afde2c456d9b4ce40689f9da6ddcdb
4
+ data.tar.gz: d40a2dae8ab2fdc9c3fe0128e5fbc4f545a0a25de1addc7ca39bd889da1cbb34
5
+ SHA512:
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
- time_zone = ActiveSupport::TimeZone.all.find { |x| x.tzinfo == ActiveSupport::TimeZone.find_tzinfo(time_zone)} if time_zone
25
- time_zone = idealized_time_zone if time_zone.nil?
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
@@ -60,7 +60,7 @@ module PseudoEntity::Randoms
60
60
  command = "random_#{name}".to_sym
61
61
  relay = arity_random?(command)
62
62
  if !relay
63
- size = /.*_(\d+)$/.match(name)[1].to_i
63
+ size = /.*_(\d+)$/.match(name.to_s)[1].to_i
64
64
  command = (/(.*)_\d+$/.match(name.to_s)[1]).to_sym
65
65
  object = Kernel
66
66
  end
@@ -1,3 +1,3 @@
1
1
  class PseudoEntity
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/pseudo_entity.rb CHANGED
@@ -44,6 +44,16 @@ class PseudoEntity
44
44
  self
45
45
  end
46
46
 
47
+ def reset(value_name)
48
+ value_name = value_name.to_s.to_sym
49
+ if self.respond_to?(value_name)
50
+ instance_variable_set("@#{value_name}".to_sym, nil)
51
+ self.send(value_name)
52
+ else
53
+ nil
54
+ end
55
+ end
56
+
47
57
  def street_address
48
58
  # Yes it is in 2-1 order because that's how the US Post Office says to do it.
49
59
  # Apartment, Suites, etc go on the first line if there are two lines or at the end of the single line
metadata CHANGED
@@ -1,149 +1,135 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pseudo_entity
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Frank Hall
14
- autorequire:
15
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
16
10
  cert_chain: []
17
-
18
- date: 2013-06-06 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2022-07-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: bundler
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 9
29
- segments:
30
- - 1
31
- - 3
32
- version: "1.3"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.3'
33
20
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rake
37
21
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13'
47
34
  type: :development
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: rspec
51
35
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ~>
56
- - !ruby/object:Gem::Version
57
- hash: 25
58
- segments:
59
- - 2
60
- - 13
61
- version: "2.13"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
62
48
  type: :development
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: uuidtools
66
49
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ~>
71
- - !ruby/object:Gem::Version
72
- hash: 1
73
- segments:
74
- - 2
75
- - 1
76
- version: "2.1"
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: uuidtools
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.2'
77
62
  type: :runtime
78
- version_requirements: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: activesupport
81
63
  prerelease: false
82
- requirement: &id005 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 2
90
- - 0
91
- version: "2.0"
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '7'
92
76
  type: :runtime
93
- version_requirements: *id005
94
- - !ruby/object:Gem::Dependency
95
- name: iconv
96
77
  prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
106
- type: :runtime
107
- version_requirements: *id006
108
- - !ruby/object:Gem::Dependency
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '7'
83
+ - !ruby/object:Gem::Dependency
109
84
  name: tzinfo
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2'
90
+ type: :runtime
110
91
  prerelease: false
111
- requirement: &id007 !ruby/object:Gem::Requirement
112
- none: false
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- hash: 3
117
- segments:
118
- - 0
119
- version: "0"
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: tzinfo-data
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1'
120
104
  type: :runtime
121
- version_requirements: *id007
122
- - !ruby/object:Gem::Dependency
123
- name: huge_enumerable
124
105
  prerelease: false
125
- requirement: &id008 !ruby/object:Gem::Requirement
126
- none: false
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- hash: 3
131
- segments:
132
- - 0
133
- version: "0"
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: huge_enumerable
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.1'
134
118
  type: :runtime
135
- version_requirements: *id008
136
- description: A class for generating realistic looking data for people, companies, etc.
137
- email:
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.1'
125
+ description: A class for generating realistic looking data for people, companies,
126
+ etc.
127
+ email:
138
128
  - ChapterHouse.Dune@gmail.com
139
129
  executables: []
140
-
141
130
  extensions: []
142
-
143
131
  extra_rdoc_files: []
144
-
145
- files:
146
- - .gitignore
132
+ files:
147
133
  - Gemfile
148
134
  - LICENSE.txt
149
135
  - README.md
@@ -155,44 +141,29 @@ files:
155
141
  - lib/pseudo_entity/randoms/locations_hash.rb
156
142
  - lib/pseudo_entity/randoms/zip_code_database.csv
157
143
  - lib/pseudo_entity/version.rb
158
- - psuedo_entity.gemspec
159
- - spec/lib/pseudo_entity/randoms_spec.rb
160
- - spec/lib/pseudo_entity_spec.rb
161
- - spec/spec_helper.rb
162
- homepage: http://chapterhouse.github.io/pseudo_entity
163
- licenses:
144
+ homepage: https://github.com/ChapterHouse/pseudo_entity
145
+ licenses:
164
146
  - MIT
165
- post_install_message:
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:
166
151
  rdoc_options: []
167
-
168
- require_paths:
152
+ require_paths:
169
153
  - lib
170
- required_ruby_version: !ruby/object:Gem::Requirement
171
- none: false
172
- requirements:
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
173
156
  - - ">="
174
- - !ruby/object:Gem::Version
175
- hash: 3
176
- segments:
177
- - 0
178
- version: "0"
179
- required_rubygems_version: !ruby/object:Gem::Requirement
180
- none: false
181
- requirements:
157
+ - !ruby/object:Gem::Version
158
+ version: '3.0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
182
161
  - - ">="
183
- - !ruby/object:Gem::Version
184
- hash: 3
185
- segments:
186
- - 0
187
- version: "0"
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
188
164
  requirements: []
189
-
190
- rubyforge_project:
191
- rubygems_version: 1.8.25
192
- signing_key:
193
- specification_version: 3
165
+ rubygems_version: 3.2.32
166
+ signing_key:
167
+ specification_version: 4
194
168
  summary: A class for generating realistic looking data for people, companies, etc.
195
- test_files:
196
- - spec/lib/pseudo_entity/randoms_spec.rb
197
- - spec/lib/pseudo_entity_spec.rb
198
- - spec/spec_helper.rb
169
+ test_files: []
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- Gemfile.lock
6
- InstalledFiles
7
- coverage
8
- InstalledFiles
9
- lib/bundler/man
10
- pkg
11
- rdoc
12
- spec/reports
13
- test/tmp
14
- test/version_tmp
15
- tmp
16
-
17
- # YARD artifacts
18
- .yardoc
19
- _yardoc
20
- doc/
@@ -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,276 +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
- end
261
-
262
- context "as itself" do
263
-
264
- subject(:random) { PseudoEntity::Randoms }
265
-
266
- it "should create a token smaller than 32 characters" do
267
- random.token(3).size.should eq(3)
268
- end
269
-
270
- it "should create a token larger than 32 characters" do
271
- random.token(128).size.should eq(128)
272
- end
273
-
274
- end
275
-
276
- end
@@ -1,157 +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
- names = [ 'Jack', 'Jill' ]
69
- pseudo_entity = PseudoEntity.new
70
- pseudo_entity.stub(:random_first_name).and_return(names.shift)
71
- pseudo_entity.first_name.should equal(pseudo_entity.first_name)
72
- end
73
-
74
- it "should return new values after a reset" do
75
- names = [ 'Jack', 'Jill' ]
76
- pseudo_entity = PseudoEntity.new
77
- pseudo_entity.stub(:random_first_name).and_return(names.shift)
78
- name = pseudo_entity.first_name
79
- pseudo_entity.reset!
80
- pseudo_entity.stub(:random_first_name).and_return(names.shift)
81
- pseudo_entity.first_name.should_not eql(name)
82
- end
83
-
84
- it "should return self after a reset" do
85
- pseudo_entity.reset!.should equal(pseudo_entity)
86
- end
87
-
88
- it "should combine addresses in 2,1 order" do
89
- pseudo_entity.stub(:street_address_line_1).and_return(:street_address_line_1)
90
- pseudo_entity.stub(:street_address_line_2).and_return(:street_address_line_2)
91
- pseudo_entity.street_address.should eql('street_address_line_2 street_address_line_1')
92
- end
93
-
94
- it "should trim missing street information" do
95
- pseudo_entity.stub(:street_address_line_1).and_return(:street_address_line_1)
96
- pseudo_entity.stub(:street_address_line_2).and_return('')
97
- pseudo_entity.street_address.should == 'street_address_line_1'
98
- pseudo_entity.stub(:street_address_line_1).and_return('')
99
- pseudo_entity.stub(:street_address_line_2).and_return(:street_address_line_2)
100
- pseudo_entity.street_address.should eql('street_address_line_2')
101
- end
102
-
103
- it "should apartment number as street address line 1 when the address is at an apartment" do
104
- apartment_number = 1234
105
- pseudo_entity.stub(:apartment_number).and_return(apartment_number)
106
- pseudo_entity.stub(:apartment?).and_return(true)
107
- pseudo_entity.stub(:suite?).and_return(false)
108
- pseudo_entity.street_address_line_1.should eql("APT #{apartment_number}")
109
- end
110
-
111
- it "should suite number as street address line 1 when the address is at a suite" do
112
- suite_number = 1234
113
- pseudo_entity.stub(:suite_number).and_return(suite_number)
114
- pseudo_entity.stub(:apartment?).and_return(false)
115
- pseudo_entity.stub(:suite?).and_return(true)
116
- pseudo_entity.street_address_line_1.should eql("STE #{suite_number}")
117
- end
118
-
119
- it "should use the street position as street address line 1 when not at an apartment or suite" do
120
- pseudo_entity.stub(:apartment?).and_return(false)
121
- pseudo_entity.stub(:suite?).and_return(false)
122
- pseudo_entity.street_address_line_1.should eql(street_position)
123
- end
124
-
125
- it "should use street position as street address line 2 when a street modifier is needed" do
126
- pseudo_entity.stub(:street_modifier_needed?).and_return(true)
127
- pseudo_entity.street_address_line_2.should eql(street_position)
128
- end
129
-
130
- it "should return nil as street address line 2 when a street modifier is not needed" do
131
- pseudo_entity.stub(:street_modifier_needed?).and_return(false)
132
- pseudo_entity.street_address_line_2.should be_nil
133
- end
134
-
135
- it "should identify when an address is and is not an suite" do
136
- pseudo_entity.stub(:street_modifier_needed).and_return(:suite)
137
- pseudo_entity.suite?.should be_true
138
- pseudo_entity.stub(:street_modifier_needed).and_return(:something_else)
139
- pseudo_entity.suite?.should be_false
140
- end
141
-
142
- it "should generate a yelp business id from the company name and the city" do
143
- pseudo_entity.yelp_business_id.should == 'Some-Company-Ltd-St-Archibald'
144
- end
145
-
146
- it "should generate a yelp business url from the yelp business id" do
147
- pseudo_entity.stub(:yelp_business_id).and_return(:yelp_business_id)
148
- pseudo_entity.yelp_business_url.should == 'http://www.yelp.com/biz/yelp_business_id'
149
- end
150
-
151
- it "should generate a string 22 characters long for yelp user id" do
152
- yelp_user_id = pseudo_entity.yelp_user_id
153
- yelp_user_id.should be_an_instance_of(String)
154
- yelp_user_id.size.should eql(22)
155
- end
156
-
157
- end
data/spec/spec_helper.rb DELETED
@@ -1 +0,0 @@
1
- require 'pseudo_entity'