nic_ar 0.0.2 → 0.0.3

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.
@@ -1,3 +1,3 @@
1
1
  module NicAr
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/nic_ar.gemspec CHANGED
@@ -13,7 +13,8 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = "https://github.com/vivaserver/nic_ar"
14
14
 
15
15
  gem.add_runtime_dependency 'rest-client', '~> 1.6'
16
- gem.add_development_dependency 'minitest', '~> 3.3.0'
16
+ gem.add_development_dependency 'minitest', '~> 3.3'
17
+ gem.add_development_dependency 'webmock', '~> 1.8'
17
18
 
18
19
  gem.files = `git ls-files`.split($/)
19
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
data/spec/client_spec.rb CHANGED
@@ -1,104 +1,94 @@
1
1
  require_relative 'spec_helper'
2
2
 
3
- describe 'nic!alert API client' do
3
+ describe 'NicAr::Client' do
4
4
  it 'raises ArgumentError if no parameter to resource given' do
5
5
  proc { NicAr::Client.people }.must_raise ArgumentError
6
6
  end
7
7
 
8
8
  describe 'using stubbed API responses' do
9
9
  it 'has flexible support for multiple arguments' do
10
- RestClient.stub :get, response('transactions/macusadas.com.ar.REN') do
11
- result = NicAr::Client.domains 'macusadas.com.ar', 'transactions'
12
- result.must_be_instance_of Array
13
- transaction = result.first
14
- transaction.must_be_instance_of Hash
15
- transaction['id'].must_equal 'REN17330833'
16
- transaction['status'].must_equal 'FINALIZADO'
17
- transaction['description'].must_equal 'Renovacion de Nombre'
18
- end
10
+ stub_request(:get,/domains\/macusadas\.com\.ar\/transactions$/).to_return(:body => stub_for('transactions/macusadas.com.ar.REN'))
11
+ result = NicAr::Client.domains 'macusadas.com.ar', 'transactions'
12
+ result.must_be_instance_of Array
13
+ transaction = result.first
14
+ transaction.must_be_instance_of Hash
15
+ transaction['id'].must_equal 'REN17330833'
16
+ transaction['status'].must_equal 'FINALIZADO'
17
+ transaction['description'].must_equal 'Renovacion de Nombre'
19
18
  end
20
19
 
21
20
  describe 'DNS lookups' do
22
21
  it 'returns a hash for primary DNS lookups' do
23
- RestClient.stub :get, response('dns_servers/ns1.sedoparking.com') do
24
- result = NicAr::Client.dns_servers 'ns1.sedoparking.com'
25
- result.must_be_instance_of Hash
26
- result['host'].must_equal 'ns1.sedoparking.com'
27
- result['handle'].must_equal 'NICAR-H24966'
28
- end
22
+ stub_request(:get,/dns_servers\/ns1\.sedoparking\.com$/).to_return(:body => stub_for('dns_servers/ns1.sedoparking.com'))
23
+ result = NicAr::Client.dns_servers 'ns1.sedoparking.com'
24
+ result.must_be_instance_of Hash
25
+ result['host'].must_equal 'ns1.sedoparking.com'
26
+ result['handle'].must_equal 'NICAR-H24966'
29
27
  end
30
28
 
31
29
  it 'returns a hash for secondary DNS lookups' do
32
- RestClient.stub :get, response('dns_servers/ns2.sedoparking.com') do
33
- result = NicAr::Client.dns_servers 'ns2.sedoparking.com'
34
- result.must_be_instance_of Hash
35
- result['host'].must_equal 'ns2.sedoparking.com'
36
- result['handle'].must_equal 'NICAR-H24965'
37
- end
30
+ stub_request(:get,/dns_servers\/ns2\.sedoparking\.com$/).to_return(:body => stub_for('dns_servers/ns2.sedoparking.com'))
31
+ result = NicAr::Client.dns_servers 'ns2.sedoparking.com'
32
+ result.must_be_instance_of Hash
33
+ result['host'].must_equal 'ns2.sedoparking.com'
34
+ result['handle'].must_equal 'NICAR-H24965'
38
35
  end
39
36
  end
40
37
 
41
38
  describe 'Domains lookups' do
42
39
  it 'returns Nil for Domain 404s' do
43
- skip
44
- RestClient.stub :get, proc { raise RestClient::ResourceNotFound } do
45
- proc { NicAr::Client.domains 'hispafuentes.com.ar' }.must_raise NicAr::NotFound
46
- end
40
+ stub_request(:get,/domains\/hispafuentes\.com\.ar$/).to_return(:status => 404)
41
+ proc { NicAr::Client.domains 'hispafuentes.com.ar' }.must_raise NicAr::NotFound
47
42
  end
48
43
 
49
44
  it 'returns a Hash for Domain lookups' do
50
- RestClient.stub :get, response('domains/dww.com.ar') do
51
- result = NicAr::Client.domains 'dww.com.ar'
52
- result.must_be_instance_of Hash
53
- result['name'].must_equal 'dww'
54
- result['domain'].must_equal '.com.ar'
55
- end
45
+ stub_request(:get,/domains\/dww\.com\.ar$/).to_return(:body => stub_for('domains/dww.com.ar'))
46
+ result = NicAr::Client.domains 'dww.com.ar'
47
+ result.must_be_instance_of Hash
48
+ result['name'].must_equal 'dww'
49
+ result['domain'].must_equal '.com.ar'
56
50
  end
57
51
  end
58
52
 
59
53
  describe 'Entities lookups' do
60
54
  it 'returns an Entity hash for lookups' do
61
- RestClient.stub :get, response('entities/Sedo.com LLC') do
62
- result = NicAr::Client.entities 'Sedo.com LLC'
63
- result.must_be_instance_of Hash
64
- result['name'].must_equal 'Sedo.com LLC'
65
- result['handle'].must_equal 'NICAR-E779784'
66
- end
55
+ stub_request(:get,/entities\/Sedo\.com.LLC$/).to_return(:body => stub_for('entities/Sedo.com LLC'))
56
+ result = NicAr::Client.entities 'Sedo.com LLC'
57
+ result.must_be_instance_of Hash
58
+ result['name'].must_equal 'Sedo.com LLC'
59
+ result['handle'].must_equal 'NICAR-E779784'
67
60
  end
68
61
  end
69
62
 
70
- describe 'Persons lookups' do
63
+ describe 'People lookups' do
71
64
  it 'returns a Person hash for lookups' do
72
- RestClient.stub :get, response('persons/Sedo.com LLC - Technical Contact') do
73
- result = NicAr::Client.persons 'Sedo.com LLC - Technical Contact'
74
- result.must_be_instance_of Hash
75
- result['name'].must_equal 'Sedo.com LLC - Technical Contact'
76
- result['handle'].must_equal 'NICAR-P1280916'
77
- end
65
+ stub_request(:get,/people\/Sedo\.com.LLC.-.Technical.Contact$/).to_return(:body => stub_for('people/Sedo.com LLC - Technical Contact'))
66
+ result = NicAr::Client.people 'Sedo.com LLC - Technical Contact'
67
+ result.must_be_instance_of Hash
68
+ result['name'].must_equal 'Sedo.com LLC - Technical Contact'
69
+ result['handle'].must_equal 'NICAR-P1280916'
78
70
  end
79
71
  end
80
72
 
81
73
  describe 'Transactions lookups' do
82
74
  it 'returns a Transactions array for domains lookups' do
83
- RestClient.stub :get, response('transactions/macusadas.com.ar.REN') do
84
- result = NicAr::Client.transactions 'macusadas.com.ar'
85
- result.must_be_instance_of Array
86
- result.count.must_equal 1
87
- transaction = result.first
88
- transaction.must_be_instance_of Hash
89
- transaction['id'].must_equal 'REN17330833'
90
- transaction['status'].must_equal 'FINALIZADO'
91
- transaction['description'].must_equal 'Renovacion de Nombre'
92
- end
75
+ stub_request(:get,/transactions\/macusadas\.com\.ar$/).to_return(:body => stub_for('transactions/macusadas.com.ar.REN'))
76
+ result = NicAr::Client.transactions 'macusadas.com.ar'
77
+ result.must_be_instance_of Array
78
+ result.count.must_equal 1
79
+ transaction = result.first
80
+ transaction.must_be_instance_of Hash
81
+ transaction['id'].must_equal 'REN17330833'
82
+ transaction['status'].must_equal 'FINALIZADO'
83
+ transaction['description'].must_equal 'Renovacion de Nombre'
93
84
  end
94
85
 
95
86
  it 'returns a Transaction hash for single transaction lookups' do
96
- RestClient.stub :get, response('transactions/REN17330833') do
97
- result = NicAr::Client.transactions 'REN17330833'
98
- result['domain'].must_equal 'macusadas.com.ar'
99
- result['status'].must_equal 'FINALIZADO'
100
- result['description'].must_equal 'Renovacion de Nombre'
101
- end
87
+ stub_request(:get,/transactions\/REN17330833$/).to_return(:body => stub_for('transactions/REN17330833'))
88
+ result = NicAr::Client.transactions 'REN17330833'
89
+ result['domain'].must_equal 'macusadas.com.ar'
90
+ result['status'].must_equal 'FINALIZADO'
91
+ result['description'].must_equal 'Renovacion de Nombre'
102
92
  end
103
93
  end
104
94
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative '../lib/nic_ar'
2
2
  require 'minitest/autorun'
3
+ require 'webmock/minitest'
3
4
 
4
- def response(request)
5
- JSON.parse(File.read(File.join(File.dirname(__FILE__),'stubs',"#{request}.json")))
5
+ def stub_for(request)
6
+ File.read(File.join(File.dirname(__FILE__),'stubs',"#{request}.json"))
6
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nic_ar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-11-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &72038150 !ruby/object:Gem::Requirement
16
+ requirement: &84464410 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,18 +21,29 @@ dependencies:
21
21
  version: '1.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *72038150
24
+ version_requirements: *84464410
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &72037900 !ruby/object:Gem::Requirement
27
+ requirement: &84464150 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 3.3.0
32
+ version: '3.3'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *72037900
35
+ version_requirements: *84464150
36
+ - !ruby/object:Gem::Dependency
37
+ name: webmock
38
+ requirement: &84463840 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '1.8'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *84463840
36
47
  description: A simple client for ".ar" (Argentina) domain names lookup
37
48
  email:
38
49
  - cristian.arroyo@vivaserver.com
@@ -55,7 +66,7 @@ files:
55
66
  - spec/stubs/dns_servers/ns2.sedoparking.com.json
56
67
  - spec/stubs/domains/dww.com.ar.json
57
68
  - spec/stubs/entities/Sedo.com LLC.json
58
- - spec/stubs/persons/Sedo.com LLC - Technical Contact.json
69
+ - spec/stubs/people/Sedo.com LLC - Technical Contact.json
59
70
  - spec/stubs/transactions/REN17330833.json
60
71
  - spec/stubs/transactions/macusadas.com.ar.REN.json
61
72
  homepage: https://github.com/vivaserver/nic_ar
@@ -90,6 +101,6 @@ test_files:
90
101
  - spec/stubs/dns_servers/ns2.sedoparking.com.json
91
102
  - spec/stubs/domains/dww.com.ar.json
92
103
  - spec/stubs/entities/Sedo.com LLC.json
93
- - spec/stubs/persons/Sedo.com LLC - Technical Contact.json
104
+ - spec/stubs/people/Sedo.com LLC - Technical Contact.json
94
105
  - spec/stubs/transactions/REN17330833.json
95
106
  - spec/stubs/transactions/macusadas.com.ar.REN.json