skype_check 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +59 -0
- data/Guardfile +24 -0
- data/LICENSE +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/example/demo.rb +33 -0
- data/lib/skype_check.rb +4 -0
- data/lib/skype_check/config.rb +28 -0
- data/lib/skype_check/http_service.rb +34 -0
- data/lib/skype_check/query_error.rb +14 -0
- data/lib/skype_check/username.rb +33 -0
- data/lib/skype_check/username_validation_error.rb +4 -0
- data/lib/skype_check/version.rb +3 -0
- data/skype_check.gemspec +28 -0
- data/spec/lib/config_spec.rb +25 -0
- data/spec/lib/username_spec.rb +66 -0
- data/spec/spec_helper.rb +9 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aa5c71dec33830855f7aecfa648b934313926fde
|
4
|
+
data.tar.gz: d030748ecf22b21b05857c38b5e8f9df85ed1118
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62fba4b969c1330973962de8b22daa9f9b39c91e97ebaf0885ec7cce0dac665ac0d550bf8d01d76b6947df3bc76853d8b981e9c472c8d7a360f078737c0113f9
|
7
|
+
data.tar.gz: da710fbb5fe34c5c5b0db7888f05b754b7a0471fa0fe5a6ad1db2236f2d8c0be12fb25ff4d7d4d37f936e7b653dae8f88f8f2c5d67d8cd45014931ca4ef6ce15
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
skype_check (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.3.6)
|
10
|
+
coderay (1.0.9)
|
11
|
+
crack (0.4.2)
|
12
|
+
safe_yaml (~> 1.0.0)
|
13
|
+
diff-lcs (1.2.5)
|
14
|
+
formatador (0.2.4)
|
15
|
+
guard (1.7.0)
|
16
|
+
formatador (>= 0.2.4)
|
17
|
+
listen (>= 0.6.0)
|
18
|
+
lumberjack (>= 1.0.2)
|
19
|
+
pry (>= 0.9.10)
|
20
|
+
thor (>= 0.14.6)
|
21
|
+
guard-rspec (2.5.4)
|
22
|
+
guard (>= 1.1)
|
23
|
+
rspec (~> 2.11)
|
24
|
+
listen (0.7.3)
|
25
|
+
lumberjack (1.0.3)
|
26
|
+
method_source (0.8.1)
|
27
|
+
pry (0.9.12.2)
|
28
|
+
coderay (~> 1.0.5)
|
29
|
+
method_source (~> 0.8)
|
30
|
+
slop (~> 3.4)
|
31
|
+
rake (10.1.1)
|
32
|
+
rb-fsevent (0.9.1)
|
33
|
+
rspec (2.14.1)
|
34
|
+
rspec-core (~> 2.14.0)
|
35
|
+
rspec-expectations (~> 2.14.0)
|
36
|
+
rspec-mocks (~> 2.14.0)
|
37
|
+
rspec-core (2.14.7)
|
38
|
+
rspec-expectations (2.14.5)
|
39
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
40
|
+
rspec-mocks (2.14.5)
|
41
|
+
safe_yaml (1.0.4)
|
42
|
+
slop (3.4.5)
|
43
|
+
thor (0.19.1)
|
44
|
+
webmock (1.19.0)
|
45
|
+
addressable (>= 2.3.6)
|
46
|
+
crack (>= 0.3.2)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
bundler (~> 1.3)
|
53
|
+
guard
|
54
|
+
guard-rspec
|
55
|
+
rake
|
56
|
+
rb-fsevent (~> 0.9)
|
57
|
+
rspec
|
58
|
+
skype_check!
|
59
|
+
webmock
|
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 smnplk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Simon Polak
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# SkypeCheck
|
2
|
+
|
3
|
+
This is a small gem for checking skype username availability/existance.
|
4
|
+
When (for some reason) you need to check if some skype username exists, this gem
|
5
|
+
should do the job for you.
|
6
|
+
|
7
|
+
##Install
|
8
|
+
|
9
|
+
gem install skype_check
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
```ruby
|
13
|
+
require 'skype_check'
|
14
|
+
|
15
|
+
begin
|
16
|
+
is_taken = SkypeCheck::Username.is_taken?('my_username')
|
17
|
+
#or
|
18
|
+
is_available = SkypeCheck::Username.is_available?('my_username')
|
19
|
+
rescue SkypeCheck::QueryError, SkypeCheck::UsernameValidator => e
|
20
|
+
#handle exception
|
21
|
+
puts e.message
|
22
|
+
end
|
23
|
+
```
|
24
|
+
Requests are made to Skype's username validation endpoint, which points to
|
25
|
+
'https://login.skype.com/json/validator' at the time of this writing.
|
26
|
+
|
27
|
+
But should Skype's endpoint change in the future, you set it like this
|
28
|
+
|
29
|
+
````ruby
|
30
|
+
SkypeCheck.configure { |c| c.username_validator_endpoint = '<new_url>' }
|
31
|
+
```
|
32
|
+
|
33
|
+
If you want to get back the full json response in a hash
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
begin
|
37
|
+
response = SkypeCheck::Username.query('my_username')
|
38
|
+
rescue SkypeCheck::QueryError, SkypeCheck::UsernameValidator => e
|
39
|
+
#handle exception
|
40
|
+
puts e.message
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
52
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/example/demo.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../lib/skype_check'
|
2
|
+
|
3
|
+
#Check for username 'smnplk' and get back json response as a Hash
|
4
|
+
#This is what you should get
|
5
|
+
#{"status"=>406, "status_text"=>"valid", "data"=>{"markup"=>"Skype Name not available", "alternatives"=>true,
|
6
|
+
#"fieldDetails"=>"<label>Suggestions</label><ul><li><label><input class=\"skypeNameSuggestion\"
|
7
|
+
#type=\"radio\" name=\"selectSkypeName\" value=\"smnplk1\"/>smnplk1</label>
|
8
|
+
#</li><li><label><input class=\"skypeNameSuggestion\" type=\"radio\"
|
9
|
+
#name=\"selectSkypeName\" value=\"smnplk2\"/>smnplk2</label>
|
10
|
+
#</li><li><label><input class=\"skypeNameSuggestion\" type=\"radio\" name=\"selectSkypeName\" value=\"smnplk55\"/>smnplk55</label> </li></ul>"}}
|
11
|
+
begin
|
12
|
+
response = SkypeCheck::Username.query('smnplk')
|
13
|
+
puts response
|
14
|
+
rescue SkypeCheck::QueryError, SkypeCheck::UsernameValidationError => e
|
15
|
+
puts e.message
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
begin
|
20
|
+
#Check if skype username is taken (meaning user exists)
|
21
|
+
user_1 = 'smnplk'
|
22
|
+
bool = SkypeCheck::Username.is_taken?(user_1)
|
23
|
+
puts "Username #{user_1} is #{bool ? 'taken': 'not taken'}."
|
24
|
+
|
25
|
+
#Check if skype username is available (no user with that name exists)
|
26
|
+
user_2 = 'double0071ui'
|
27
|
+
bool2 = SkypeCheck::Username.is_available?(user_2)
|
28
|
+
puts "Username #{user_2} is #{bool ? 'available': 'not available'}."
|
29
|
+
|
30
|
+
|
31
|
+
rescue SkypeCheck::QueryError, SkypeCheck::UsernameValidationError => e
|
32
|
+
puts e.message
|
33
|
+
end
|
data/lib/skype_check.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module SkypeCheck
|
2
|
+
class << self
|
3
|
+
attr_accessor :configuration
|
4
|
+
|
5
|
+
def configuration
|
6
|
+
@configuration || configure
|
7
|
+
end
|
8
|
+
|
9
|
+
def configure
|
10
|
+
@configuration = Configuration.new
|
11
|
+
yield(configuration) if block_given?
|
12
|
+
@configuration
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
class Configuration
|
18
|
+
attr_accessor :username_validator_endpoint
|
19
|
+
|
20
|
+
DEFAULT_ENDPOINT = 'https://login.skype.com/json/validator'
|
21
|
+
|
22
|
+
|
23
|
+
def username_validator_endpoint
|
24
|
+
@username_validator_endpoint || DEFAULT_ENDPOINT
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'openssl'
|
3
|
+
require_relative 'config'
|
4
|
+
require_relative 'query_error'
|
5
|
+
|
6
|
+
module SkypeCheck
|
7
|
+
|
8
|
+
module HTTPService
|
9
|
+
|
10
|
+
def http_query(username)
|
11
|
+
begin
|
12
|
+
#setup uri object with username param
|
13
|
+
uri = URI(SkypeCheck.configuration.username_validator_endpoint)
|
14
|
+
param = { new_username: username }
|
15
|
+
uri.query = URI.encode_www_form(param)
|
16
|
+
|
17
|
+
#build a request object
|
18
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
+
if uri.kind_of? URI::HTTPS
|
20
|
+
http.use_ssl = true
|
21
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
22
|
+
end
|
23
|
+
|
24
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
25
|
+
http.request(request)
|
26
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, SocketError => e
|
27
|
+
raise SkypeCheck::QueryError.new(e)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module_function :http_query
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module SkypeCheck
|
2
|
+
#wrapper around all possible network and other io exceptions
|
3
|
+
class QueryError < StandardError
|
4
|
+
attr_reader :source_error, :message
|
5
|
+
|
6
|
+
def initialize(source_error)
|
7
|
+
@source_error = source_error
|
8
|
+
end
|
9
|
+
|
10
|
+
def message
|
11
|
+
"SkypeCheck: Source error type: #{@source_error.class}, source error message: #{@source_error.message}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'config'
|
2
|
+
require_relative 'http_service'
|
3
|
+
require_relative 'username_validation_error'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module SkypeCheck
|
7
|
+
class Username
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def query(username)
|
12
|
+
raise SkypeCheck::UsernameValidationError, "Input username is nil!" if username.nil?
|
13
|
+
raise SkypeCheck::UsernameValidationError, "Input username is too long!" if username.size > 32
|
14
|
+
raise SkypeCheck::UsernameValidationError, "Input username is too short!" if username.size < 6
|
15
|
+
raise SkypeCheck::UsernameValidationError, "Input username should not start with a number!" if username.match(/\A\d/)
|
16
|
+
|
17
|
+
resp_body = SkypeCheck::HTTPService.http_query(username).body
|
18
|
+
JSON.parse(resp_body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_taken?(username)
|
22
|
+
query(username)["status"] == 406
|
23
|
+
end
|
24
|
+
|
25
|
+
#when it comes to web services it's better to be explicit with semantic meanings of http return codes, it's better than calling !is_taken?(username) here.
|
26
|
+
def is_available?(username)
|
27
|
+
query(username)["status"] == 200
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/skype_check.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'skype_check/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "skype_check"
|
8
|
+
spec.version = SkypeCheck::VERSION
|
9
|
+
spec.authors = ["Simon Polak"]
|
10
|
+
spec.email = ["smnplk@gmail.com"]
|
11
|
+
spec.description = %q{Tool for checking skype username availability}
|
12
|
+
spec.summary = %q{Check if skype username exists or is available}
|
13
|
+
spec.homepage = ""
|
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"
|
24
|
+
spec.add_development_dependency "webmock"
|
25
|
+
spec.add_development_dependency "guard"
|
26
|
+
spec.add_development_dependency "guard-rspec"
|
27
|
+
spec.add_development_dependency "rb-fsevent", "~> 0.9"
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
describe SkypeCheck do
|
3
|
+
#cleanup
|
4
|
+
after(:all) { SkypeCheck.configure { |c| c.username_validator_endpoint = SkypeCheck::Configuration::DEFAULT_ENDPOINT } }
|
5
|
+
|
6
|
+
describe "Configuration" do
|
7
|
+
|
8
|
+
context "Default configuration" do
|
9
|
+
it "returns a Configuration object with default settings" do
|
10
|
+
expect(SkypeCheck.configuration.class.name).to eq("SkypeCheck::Configuration")
|
11
|
+
expect(SkypeCheck.configuration.username_validator_endpoint).to eq('https://login.skype.com/json/validator')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "Manual configuration with a block" do
|
16
|
+
it "should override default or previous settings" do
|
17
|
+
SkypeCheck.configure do |c|
|
18
|
+
c.username_validator_endpoint = 'new_url'
|
19
|
+
end
|
20
|
+
|
21
|
+
expect(SkypeCheck.configuration.username_validator_endpoint).to eq('new_url')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
describe SkypeCheck::Username do
|
3
|
+
|
4
|
+
let(:query_url) { "#{SkypeCheck.configuration.username_validator_endpoint}?new_username=username" }
|
5
|
+
let(:successfull_response) { '{"status": 200}' }
|
6
|
+
let(:taken_response) { '{"status":406, "data": {"markup":"Skype Name not available", "alternatives":true}}' }
|
7
|
+
let(:available_response) { '{"status":200}' }
|
8
|
+
|
9
|
+
let(:too_long_username) { (0..32).map {"a"}.join }
|
10
|
+
let(:too_short_username) { 'abcde' }
|
11
|
+
|
12
|
+
describe ".query" do
|
13
|
+
context "when successfull" do
|
14
|
+
it "should return a parsed json response as Hash" do
|
15
|
+
stub_request(:get, query_url).to_return(status: 200, body: successfull_response, headers: {})
|
16
|
+
|
17
|
+
expect(SkypeCheck::Username.query('username').class).to eq(Hash)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when connection error" do
|
22
|
+
it "can raise SocketError" do
|
23
|
+
SkypeCheck::Username.should_receive(:query).with('username').and_raise(SocketError)
|
24
|
+
lambda { SkypeCheck::Username.query('username')}.should raise_error(SocketError)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when username is not valid" do
|
29
|
+
it "should raise UsernameValidationError with username that is longer than 32 chars" do
|
30
|
+
expect{ SkypeCheck::Username.query(too_long_username) }.to raise_error(SkypeCheck::UsernameValidationError, "Input username is too long!")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should raise UsernameValidationError with username that is shorter than 6 chars" do
|
34
|
+
expect{ SkypeCheck::Username.query(too_short_username) }.to raise_error(SkypeCheck::UsernameValidationError, "Input username is too short!")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should raise UsernameValidationError with username that begins with a number" do
|
38
|
+
expect{ SkypeCheck::Username.query('1_username') }.to raise_error(SkypeCheck::UsernameValidationError, "Input username should not start with a number!")
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
it "should raise UsernameValidationError when username is nil" do
|
43
|
+
expect{ SkypeCheck::Username.query(nil) }.to raise_error(SkypeCheck::UsernameValidationError, "Input username is nil!")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".is_taken?" do
|
50
|
+
it "should return true if username is already taken" do
|
51
|
+
stub_request(:get, query_url).to_return(status: 200, body: taken_response, headers: {})
|
52
|
+
|
53
|
+
expect(SkypeCheck::Username.is_taken?('username')).to eq(true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe ".is_available?" do
|
58
|
+
it "should return true if username is available" do
|
59
|
+
stub_request(:get, query_url).
|
60
|
+
to_return(status: 200, body: available_response, headers: {})
|
61
|
+
|
62
|
+
expect(SkypeCheck::Username.is_available?('username')).to eq(true)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skype_check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simon Polak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.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: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rb-fsevent
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.9'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.9'
|
111
|
+
description: Tool for checking skype username availability
|
112
|
+
email:
|
113
|
+
- smnplk@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- Guardfile
|
122
|
+
- LICENSE
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- example/demo.rb
|
127
|
+
- lib/skype_check.rb
|
128
|
+
- lib/skype_check/config.rb
|
129
|
+
- lib/skype_check/http_service.rb
|
130
|
+
- lib/skype_check/query_error.rb
|
131
|
+
- lib/skype_check/username.rb
|
132
|
+
- lib/skype_check/username_validation_error.rb
|
133
|
+
- lib/skype_check/version.rb
|
134
|
+
- skype_check.gemspec
|
135
|
+
- spec/lib/config_spec.rb
|
136
|
+
- spec/lib/username_spec.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
homepage: ''
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.0.6
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: Check if skype username exists or is available
|
162
|
+
test_files:
|
163
|
+
- spec/lib/config_spec.rb
|
164
|
+
- spec/lib/username_spec.rb
|
165
|
+
- spec/spec_helper.rb
|