fake_name_generator 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.
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +29 -0
- data/LICENSE +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +26 -0
- data/fake_name_generator.gemspec +27 -0
- data/lib/fake_name_generator.rb +187 -0
- data/spec/fake_name_generator_spec.rb +123 -0
- data/spec/fixtures/INVALID_API_KEY.xml +1 -0
- data/spec/fixtures/VALID_API_KEY.json +1 -0
- data/spec/spec_helper.rb +19 -0
- metadata +112 -0
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fake_name_generator (0.0.1)
|
5
|
+
json (>= 1.5.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.2)
|
11
|
+
fakeweb (1.3.0)
|
12
|
+
json (1.5.1)
|
13
|
+
rspec (2.5.0)
|
14
|
+
rspec-core (~> 2.5.0)
|
15
|
+
rspec-expectations (~> 2.5.0)
|
16
|
+
rspec-mocks (~> 2.5.0)
|
17
|
+
rspec-core (2.5.1)
|
18
|
+
rspec-expectations (2.5.0)
|
19
|
+
diff-lcs (~> 1.1.2)
|
20
|
+
rspec-mocks (2.5.0)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
bundler (>= 1.0.7)
|
27
|
+
fake_name_generator!
|
28
|
+
fakeweb (>= 1.3.0)
|
29
|
+
rspec (>= 2.5.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Bill Turner
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
== Name
|
2
|
+
|
3
|
+
fake_name_generator - a light weight Ruby wrapper for the FakeNameGenerator.com API
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
This is a fairly simple Ruby wrapper for the FakeNameGenerator.com API. The API returns a full name, an address, fake credit card numbers, blood type(!), weight, and even a fake UPS number.
|
8
|
+
|
9
|
+
== Caveats
|
10
|
+
|
11
|
+
When I first thought of putting together this API wrapper for FakeNameGenerator.com, they had a free API unless you needed to bulk load generated names (> 10,000). Since then, they've handed over the API-handling duties to a third party named WebServius <http://www.webservius.com/corp/>.
|
12
|
+
|
13
|
+
Now, there is a limit of 50 free API calls upon signing up, and then after that API results cost $0.001 per additional 50 requests. It's certainly not an outrageous cost, but, alas, it's no longer a free API.
|
14
|
+
|
15
|
+
It's also my first attempt at a Ruby wrapper for a web service API, so there are most likely inefficiencies and some bad code. I certainly appreciate any feedback anyone could provide. See the Contributing section below.
|
16
|
+
|
17
|
+
== Requirements
|
18
|
+
|
19
|
+
In order to use the FakeNameGenerator API, you will need to acquire an API key from FakeNameGenerator.com at <http://www.fakenamegenerator.com/api.php>. The API key actually comes from WebServius (as mentioned above), but the entrance is through the FakeNameGenerator website.
|
20
|
+
|
21
|
+
== Installation
|
22
|
+
|
23
|
+
[sudo] gem install fake_name_generator
|
24
|
+
|
25
|
+
== Usage
|
26
|
+
|
27
|
+
> fake_name = FakeNameGenerator.new(:api_key => 'VALID_KEY')
|
28
|
+
> puts fake_name.full_name
|
29
|
+
"Ignatius J. Reilly"
|
30
|
+
> puts fake_name.blood_type
|
31
|
+
"A-"
|
32
|
+
|
33
|
+
== Known Issues
|
34
|
+
|
35
|
+
* This is my first attempt at a API-wrapping gem. There are certainly better ways to do this.
|
36
|
+
|
37
|
+
== TODO
|
38
|
+
|
39
|
+
* Maybe detach the HTTP call from .new(), and move to its own method.
|
40
|
+
|
41
|
+
== Contributing
|
42
|
+
|
43
|
+
I would love some help and pointers on how to make this a better gem.
|
44
|
+
|
45
|
+
* Fork the project
|
46
|
+
* Please create a topic branch to make your changes
|
47
|
+
* Change, add, improve, upgrade, etc
|
48
|
+
* Please add tests for anything you've added, and adjust tests for things you've changed
|
49
|
+
* Make sure you rebase off of master one last time
|
50
|
+
* Send a pull request on GitHub
|
51
|
+
|
52
|
+
== Authors
|
53
|
+
|
54
|
+
* Bill Turner <billturner@gmail.com>
|
55
|
+
|
56
|
+
== License
|
57
|
+
|
58
|
+
MIT License. Copyright 2011 Bill Turner. Please see +LICENSE+.
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
begin
|
7
|
+
require 'hanna/rdoctask'
|
8
|
+
rescue LoadError
|
9
|
+
require 'rake/rdoctask'
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
13
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the fake_name_generator gem.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'fake_name_generator documentation'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README.rdoc')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
task :default => :spec
|
26
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
3
|
+
require 'fake_name_generator'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "fake_name_generator"
|
7
|
+
s.version = FakeNameGenerator::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Bill Turner"]
|
10
|
+
s.email = ["billturner@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/billturner/fake_name_generator"
|
12
|
+
s.summary = "A simple Ruby wrapper to the FakeNameGenerator.com API"
|
13
|
+
s.description = "A simple Ruby wrapper to the FakeNameGenerator.com API"
|
14
|
+
|
15
|
+
s.required_rubygems_version = ">= 1.3.6"
|
16
|
+
s.rubyforge_project = "fake_name_generator"
|
17
|
+
|
18
|
+
s.add_development_dependency "bundler", ">= 1.0.7"
|
19
|
+
s.add_development_dependency "rspec", ">= 2.5.0"
|
20
|
+
s.add_development_dependency "fakeweb", ">= 1.3.0"
|
21
|
+
s.add_dependency "json", ">= 1.5.1"
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
25
|
+
s.require_path = 'lib'
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# fake_name_generator
|
2
|
+
#
|
3
|
+
# A FakeNameGenerator.com Ruby API Wrapper
|
4
|
+
#
|
5
|
+
# Author : Bill Turner - http://brilliantcorners.org/
|
6
|
+
# Required : FakeNameGenerator.com API Key - http://www.webservius.com/services/CorbanWork/fakename
|
7
|
+
# Source Repo : http://github.com/billturner/fake_name_generator
|
8
|
+
# Gem Dependence : Net::HTTP, URI, json
|
9
|
+
# Ruby Version : Written and tested using Ruby 1.8.7 and 1.9.2.
|
10
|
+
# License : See LICENSE for details.
|
11
|
+
|
12
|
+
require 'net/http'
|
13
|
+
require 'uri'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# = Synopsis
|
17
|
+
# The fake_name_generator gem provides a simple wrapper to the
|
18
|
+
# FakeNameGenerator.com API, which provides a randomized name,
|
19
|
+
# address information, as well as other indentifying information.
|
20
|
+
#
|
21
|
+
# == Example
|
22
|
+
# require 'fake_name_generator'
|
23
|
+
#
|
24
|
+
# fake_name = FakeNameGenerator.new(:api_key => 'VALID_API_KEY)
|
25
|
+
# puts fake_name.full_name
|
26
|
+
# puts fake_name.phone_number
|
27
|
+
# puts fake_name.blood_type
|
28
|
+
#
|
29
|
+
# If you would like to receive non-US English results, you can
|
30
|
+
# specify a country and nameset to use at the +new+ call:
|
31
|
+
#
|
32
|
+
# fake_name = FakeNameGenerator.new(
|
33
|
+
# :api_key => 'VALID_API_KEY',
|
34
|
+
# :country => 'it',
|
35
|
+
# :nameset => 'it')
|
36
|
+
#
|
37
|
+
# To see what options are available for country and nameset, see
|
38
|
+
# FakeNameGenerator::VALID_COUNTRY_CODES and
|
39
|
+
# FakeNameGenerator::VALID_NAMESET_CODES, respectively.
|
40
|
+
class FakeNameGenerator
|
41
|
+
|
42
|
+
##
|
43
|
+
# The current version of the gem
|
44
|
+
VERSION = '0.0.1'
|
45
|
+
|
46
|
+
##
|
47
|
+
# The current FakeNameGenerator.com API endpoint
|
48
|
+
API_URL = 'http://svc.webservius.com/v1/CorbanWork/fakename'
|
49
|
+
DEFAULT_OUTPUT = 'json'
|
50
|
+
DEFAULT_COUNTRY = 'us'
|
51
|
+
DEFAULT_NAMESET = 'us'
|
52
|
+
DEFAULT_GENDER = '0' # random
|
53
|
+
|
54
|
+
##
|
55
|
+
# The currently valid country codes you can use
|
56
|
+
VALID_COUNTRY_CODES = ['as', 'au', 'bg', 'ca', 'cyen', 'cygk', 'dk', 'fi', 'fr', 'gr', 'hu', 'is', 'it', 'nl', 'no', 'pl', 'sl', 'sp', 'sw', 'sz', 'uk', 'us']
|
57
|
+
##
|
58
|
+
# The currently valid nameset codes you can use
|
59
|
+
VALID_NAMESET_CODES = [ 'ar', 'au', 'ch', 'dk', 'en', 'er', 'fa', 'fi', 'fr', 'gd', 'gr', 'hr', 'hu', 'ig', 'is', 'it', 'jp', 'jpja', 'nl', 'pl', 'sl', 'sp', 'sw', 'us', 'vn', 'zhtw']
|
60
|
+
##
|
61
|
+
# The currently valid gender codes you can use
|
62
|
+
# 0 = random
|
63
|
+
# 1 = male
|
64
|
+
# 2 = female
|
65
|
+
VALID_GENDER_CODES = ['0', '1', '2']
|
66
|
+
|
67
|
+
class APIConnectionError < StandardError; end
|
68
|
+
class APIKeyInvalidError < StandardError; end
|
69
|
+
|
70
|
+
attr_reader :country,
|
71
|
+
:nameset,
|
72
|
+
:gender,
|
73
|
+
:data
|
74
|
+
attr_accessor :full_name,
|
75
|
+
:first_name,
|
76
|
+
:middle_name,
|
77
|
+
:last_name,
|
78
|
+
:maiden_name,
|
79
|
+
:email_address,
|
80
|
+
:gender_name,
|
81
|
+
:street1,
|
82
|
+
:street2,
|
83
|
+
:street3,
|
84
|
+
:city,
|
85
|
+
:state,
|
86
|
+
:zip,
|
87
|
+
:country_code,
|
88
|
+
:phone_number,
|
89
|
+
:birthday,
|
90
|
+
:occupation,
|
91
|
+
:password,
|
92
|
+
:domain,
|
93
|
+
:cc_type,
|
94
|
+
:cc_number,
|
95
|
+
:cc_exp_month,
|
96
|
+
:cc_exp_year,
|
97
|
+
:cc_cvv,
|
98
|
+
:national_id,
|
99
|
+
:national_id_type,
|
100
|
+
:blood_type,
|
101
|
+
:weight_kilograms,
|
102
|
+
:weight_pounds,
|
103
|
+
:height_centimeters,
|
104
|
+
:height_inches,
|
105
|
+
:ups_tracking_number
|
106
|
+
|
107
|
+
# === Parameters
|
108
|
+
# * _api_key_ = API key for accessing the FakeNameGenerator.com API (required)
|
109
|
+
# * _country_ = country-related values returned (default: 'us')
|
110
|
+
# * _nameset_ = language-related names returned (default: 'us')
|
111
|
+
# * _gender_ = specify whether random, male, or female values returned (default: random)
|
112
|
+
def initialize(options={})
|
113
|
+
@api_key = options[:api_key] or raise ArgumentError, "No API key provided"
|
114
|
+
@country = options[:country] || DEFAULT_COUNTRY
|
115
|
+
@nameset = options[:nameset] || DEFAULT_NAMESET
|
116
|
+
@gender = options[:gender] || DEFAULT_GENDER
|
117
|
+
|
118
|
+
raise ArgumentError, "Specified country parameter is not valid. Please see FakeNameGenerator::VALID_COUNTRY_CODES" unless VALID_COUNTRY_CODES.include?(@country)
|
119
|
+
raise ArgumentError, "Specified nameset parameter is not valid. Please see FakeNameGenerator::VALID_NAMESET_CODES" unless VALID_NAMESET_CODES.include?(@nameset)
|
120
|
+
raise ArgumentError, "Specified gender parameter is not valid. Please see FakeNameGenerator::VALID_GENDER_CODES" unless VALID_GENDER_CODES.include?(@gender)
|
121
|
+
|
122
|
+
url = [API_URL, build_params].join('?')
|
123
|
+
response = Net::HTTP.get_response(URI.parse(url))
|
124
|
+
|
125
|
+
case response.code
|
126
|
+
when '500' || 500
|
127
|
+
raise APIConnectionError, "FakeNameGenerator API not working (500 Error)"
|
128
|
+
when '403' || 403
|
129
|
+
raise APIKeyInvalidError, "Provided API key is not valid (403 Error)"
|
130
|
+
when '200' || 200
|
131
|
+
@data = JSON.parse(response.body)
|
132
|
+
build_name
|
133
|
+
else
|
134
|
+
raise StandardError, "Unexpected response from FakeNameGenerator.com API"
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def build_params
|
142
|
+
"wsvKey=#{@api_key}&output=#{DEFAULT_OUTPUT}&c=#{@country}&n=#{@nameset}&gen=#{@gender}"
|
143
|
+
end
|
144
|
+
|
145
|
+
def build_name
|
146
|
+
# name, gender info
|
147
|
+
@gender_name = data['identity']['gender']['value']
|
148
|
+
@full_name = data['identity']['full_name']['value']
|
149
|
+
@first_name = data['identity']['given_name']['value']
|
150
|
+
@middle_name = data['identity']['middle_name']['value']
|
151
|
+
@last_name = data['identity']['surname']['value']
|
152
|
+
@maiden_name = data['identity']['maiden_name']['value']
|
153
|
+
@email_address = data['identity']['email_address']['value']
|
154
|
+
# street address
|
155
|
+
@street1 = data['identity']['street1']['value']
|
156
|
+
@street2 = data['identity']['street2']['value']
|
157
|
+
@street3 = data['identity']['street3']['value']
|
158
|
+
@city = data['identity']['city']['value']
|
159
|
+
@state = data['identity']['state']['value']
|
160
|
+
@zip = data['identity']['zip']['value']
|
161
|
+
@country_code = data['identity']['country_code']['value']
|
162
|
+
@phone_number = data['identity']['phone_number']['value']
|
163
|
+
# misc personal info
|
164
|
+
@birthday = data['identity']['birthday']['value']
|
165
|
+
@occupation = data['identity']['occupation']['value']
|
166
|
+
@password = data['identity']['password']['value']
|
167
|
+
@domain = data['identity']['domain']['value']
|
168
|
+
# credit card info
|
169
|
+
@cc_type = data['identity']['cc_type']['value']
|
170
|
+
@cc_number = data['identity']['cc_number']['value']
|
171
|
+
@cc_exp_month = data['identity']['cc_exp_month']['value']
|
172
|
+
@cc_exp_year = data['identity']['cc_exp_year']['value']
|
173
|
+
@cc_cvv = data['identity']['cc_cvv']['value']
|
174
|
+
# identifying information
|
175
|
+
@national_id = data['identity']['national_id']['value']
|
176
|
+
@national_id_type = data['identity']['national_id_type']['value']
|
177
|
+
@blood_type = data['identity']['blood_type']['value']
|
178
|
+
@weight_kilograms = data['identity']['weight_kilograms']['value']
|
179
|
+
@weight_pounds = data['identity']['weight_pounds']['value']
|
180
|
+
@height_centimeters = data['identity']['height_centimeters']['value']
|
181
|
+
@height_inches = data['identity']['height_inches']['value']
|
182
|
+
@ups_tracking_number = data['identity']['ups_tracking_number']['value']
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FakeNameGenerator do
|
4
|
+
|
5
|
+
describe "VERSION" do
|
6
|
+
|
7
|
+
it "should have a version" do
|
8
|
+
FakeNameGenerator::VERSION.should_not be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "runtime validations" do
|
14
|
+
|
15
|
+
it "should fail if no API key was supplied" do
|
16
|
+
lambda { fake = FakeNameGenerator.new }.should raise_error(ArgumentError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return object if API key was supplied" do
|
20
|
+
fake = FakeNameGenerator.new(:api_key => 'VALID_API_KEY')
|
21
|
+
fake.class.should == FakeNameGenerator
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should use default parameters if none are specified" do
|
25
|
+
@fake = FakeNameGenerator.new(:api_key => 'VALID_API_KEY')
|
26
|
+
@fake.country.should == FakeNameGenerator::DEFAULT_COUNTRY
|
27
|
+
@fake.nameset.should == FakeNameGenerator::DEFAULT_NAMESET
|
28
|
+
@fake.gender.should == FakeNameGenerator::DEFAULT_GENDER
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should use provided parameters if provided" do
|
32
|
+
@fake = FakeNameGenerator.new(:api_key => 'VALID_API_KEY', :country => 'uk', :nameset => 'pl', :gender => '1')
|
33
|
+
@fake.country.should == 'uk'
|
34
|
+
@fake.nameset.should == 'pl'
|
35
|
+
@fake.gender.should == '1'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should allow a valid option for country" do
|
39
|
+
lambda { FakeNameGenerator.new(:api_key => 'VALID_API_KEY', :country => 'uk') }.should_not raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not allow an invalid option for country" do
|
43
|
+
lambda { FakeNameGenerator.new(:api_key => 'VALID_API_KEY', :country => 'XXX') }.should raise_error(ArgumentError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should allow a valid option for nameset" do
|
47
|
+
lambda { FakeNameGenerator.new(:api_key => 'VALID_API_KEY', :nameset => 'pl') }.should_not raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should not allow an invalid option for nameset" do
|
51
|
+
lambda { FakeNameGenerator.new(:api_key => 'VALID_API_KEY', :nameset => 'XXX') }.should raise_error(ArgumentError)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should allow a valid option for gender" do
|
55
|
+
lambda { FakeNameGenerator.new(:api_key => 'VALID_API_KEY', :gender => '2') }.should_not raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should not allow an invalid option for gender" do
|
59
|
+
lambda { FakeNameGenerator.new(:api_key => 'VALID_API_KEY', :gender => '3') }.should raise_error(ArgumentError)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
#context "invalid api key" do
|
65
|
+
|
66
|
+
##it "should return an error" do
|
67
|
+
##lambda { FakeNameGenerator.new(:api_key => 'INVALID_API_KEY') }.should raise_error(FakeNameGenerator::APIKeyInvalidError)
|
68
|
+
##end
|
69
|
+
|
70
|
+
#end
|
71
|
+
|
72
|
+
context "valid api key" do
|
73
|
+
|
74
|
+
before do
|
75
|
+
@fake = FakeNameGenerator.new(:api_key => 'VALID_API_KEY')
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should fill in the name fields" do
|
79
|
+
@fake.full_name.should_not be_empty
|
80
|
+
@fake.first_name.should_not be_empty
|
81
|
+
@fake.middle_name.should_not be_empty
|
82
|
+
@fake.last_name.should_not be_empty
|
83
|
+
@fake.maiden_name.should_not be_empty
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should fill in the address fields" do
|
87
|
+
@fake.street1.should_not be_empty
|
88
|
+
@fake.street2.should_not be_empty
|
89
|
+
@fake.city.should_not be_empty
|
90
|
+
@fake.state.should_not be_empty
|
91
|
+
@fake.zip.should_not be_empty
|
92
|
+
@fake.country_code.should_not be_empty
|
93
|
+
@fake.phone_number.should_not be_empty
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should fill in the credit card fields" do
|
97
|
+
@fake.cc_type.should_not be_empty
|
98
|
+
@fake.cc_number.should_not be_empty
|
99
|
+
@fake.cc_exp_month.should_not be_nil
|
100
|
+
@fake.cc_exp_year.should_not be_nil
|
101
|
+
@fake.cc_cvv.should_not be_empty
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should fill in the other random values" do
|
105
|
+
@fake.gender_name.should_not be_empty
|
106
|
+
@fake.birthday.should_not be_empty
|
107
|
+
@fake.occupation.should_not be_empty
|
108
|
+
@fake.password.should_not be_empty
|
109
|
+
@fake.domain.should_not be_empty
|
110
|
+
@fake.national_id.should_not be_empty
|
111
|
+
@fake.national_id_type.should_not be_empty
|
112
|
+
@fake.blood_type.should_not be_empty
|
113
|
+
@fake.weight_kilograms.should_not be_nil
|
114
|
+
@fake.weight_pounds.should_not be_nil
|
115
|
+
@fake.height_centimeters.should_not be_nil
|
116
|
+
@fake.height_inches.should_not be_nil
|
117
|
+
@fake.ups_tracking_number.should_not be_empty
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<wsvError xmlns="http://ns.webservius.com/2009/08" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><code>5</code><message>No active subscription was found for this service and key</message></wsvError>
|
@@ -0,0 +1 @@
|
|
1
|
+
{"identity":{"full_name":{"name":"full_name","label":"Name","value":"Robert L. Blackwell"},"given_name":{"name":"given_name","label":"Given Name","value":"Robert"},"middle_name":{"name":"middle_name","label":"Middle Name","value":"L"},"surname":{"name":"surname","label":"Surname","value":"Blackwell"},"maiden_name":{"name":"maiden_name","label":"Maiden Name","value":"Andrews"},"gender":{"name":"gender","label":"Gender","value":"male"},"email_address":{"name":"email_address","label":"Email Address","value":"Robert L. Blackwell@mailinator.com"},"street1":{"name":"street1","label":"Address","value":"1077 Rocket Drive"},"street2":{"name":"street2","label":"","value":"Minneapolis, MN 55415"},"street3":{"name":"street3","label":"","value":""},"house_number":{"name":"house_number","label":"House Number","value":1077},"street":{"name":"street","label":"Street","value":"Rocket Drive"},"city":{"name":"city","label":"City","value":"Minneapolis"},"state":{"name":"state","label":"State","value":"MN"},"zip":{"name":"zip","label":"Postal Code","value":"55415"},"country_code":{"name":"country_code","label":"Country Code","value":"US"},"phone_number":{"name":"phone_number","label":"Phone Number","value":"612-998-5596"},"birthday":{"name":"birthday","label":"Birthday","value":"7\/26\/1960"},"occupation":{"name":"occupation","label":"Occupation","value":"Education planner"},"password":{"name":"password","label":"Password","value":"ohTie3Ieyah"},"domain":{"name":"domain","label":"Domain","value":"DustingSprays.com"},"cc_type":{"name":"cc_type","label":"Credit Card Type","value":"Visa"},"cc_number":{"name":"cc_number","label":"Credit Card Number","value":"4532275278603573"},"cc_exp_month":{"name":"cc_exp_month","label":"Credit Card Expiration Month","value":12},"cc_exp_year":{"name":"cc_exp_year","label":"Credit Card Expiration Year","value":2014},"cc_cvv":{"name":"cc_cvv","label":"Credit Card CVV","value":"650"},"national_id":{"name":"national_id","label":"National ID","value":"469-08-3421"},"national_id_type":{"name":"national_id_type","label":"National ID Type","value":"SSN"},"blood_type":{"name":"blood_type","label":"Blood Type","value":"A+"},"weight_kilograms":{"name":"weight_kilograms","label":"Weight (Kilograms)","value":115.3},"weight_pounds":{"name":"weight_pounds","label":"Weight (Pounds)","value":253.7},"height_centimeters":{"name":"height_centimeters","label":"Height (Centimeters)","value":183},"height_inches":{"name":"height_inches","label":"Height (Inches)","value":72},"ups_tracking_number":{"name":"ups_tracking_number","label":"UPS Tracking Number","value":"1Z 093 01A 91 4717 506 4"}},"status":"success"}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rspec'
|
6
|
+
require 'fakeweb'
|
7
|
+
|
8
|
+
require 'fake_name_generator'
|
9
|
+
|
10
|
+
fixtures = File.dirname(File.expand_path(__FILE__)) + "/fixtures"
|
11
|
+
|
12
|
+
FakeWeb.allow_net_connect = false
|
13
|
+
|
14
|
+
FakeWeb.register_uri(:get, %r[http://svc\.webservius\.com/v1/CorbanWork/fakename\?(.*&|)wsvKey=VALID_API_KEY]i, :body => File.read("#{fixtures}/VALID_API_KEY.json", :content_type => 'text/json', :status => ['200', 'OK']))
|
15
|
+
FakeWeb.register_uri(:get, %r[http://svc\.webservius\.com/v1/CorbanWork/fakename\?(.*&|)wsvKey=INVALID_API_KEY]i, :body => File.read("#{fixtures}/INVALID_API_KEY.xml", :content_type => 'application/xml', :status => ["403", "Forbidden"]))
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
end
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fake_name_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bill Turner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-02-23 00:00:00 -05:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: bundler
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.0.7
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.5.0
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: fakeweb
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.3.0
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: json
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.5.1
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id004
|
60
|
+
description: A simple Ruby wrapper to the FakeNameGenerator.com API
|
61
|
+
email:
|
62
|
+
- billturner@gmail.com
|
63
|
+
executables: []
|
64
|
+
|
65
|
+
extensions: []
|
66
|
+
|
67
|
+
extra_rdoc_files: []
|
68
|
+
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- .rspec
|
72
|
+
- Gemfile
|
73
|
+
- Gemfile.lock
|
74
|
+
- LICENSE
|
75
|
+
- README.rdoc
|
76
|
+
- Rakefile
|
77
|
+
- fake_name_generator.gemspec
|
78
|
+
- lib/fake_name_generator.rb
|
79
|
+
- spec/fake_name_generator_spec.rb
|
80
|
+
- spec/fixtures/INVALID_API_KEY.xml
|
81
|
+
- spec/fixtures/VALID_API_KEY.json
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: https://github.com/billturner/fake_name_generator
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.3.6
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project: fake_name_generator
|
107
|
+
rubygems_version: 1.5.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: A simple Ruby wrapper to the FakeNameGenerator.com API
|
111
|
+
test_files: []
|
112
|
+
|