reg.api2 0.0.12 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +13 -10
- data/lib/reg_api2/domain.rb +9 -0
- data/lib/reg_api2/service.rb +4 -1
- data/lib/reg_api2/shop.rb +69 -0
- data/lib/reg_api2/version.rb +1 -1
- data/lib/reg_api2.rb +9 -1
- data/reg.api2.gemspec +2 -1
- data/spec/lib/reg_api2/bill_spec.rb +23 -23
- data/spec/lib/reg_api2/common_spec.rb +7 -7
- data/spec/lib/reg_api2/domain_spec.rb +17 -4
- data/spec/lib/reg_api2/entity/entity_base_spec.rb +4 -4
- data/spec/lib/reg_api2/folder_spec.rb +9 -9
- data/spec/lib/reg_api2/hosting_spec.rb +3 -3
- data/spec/lib/reg_api2/impl_spec.rb +16 -16
- data/spec/lib/reg_api2/request_contract_spec.rb +2 -2
- data/spec/lib/reg_api2/result_contract_spec.rb +9 -9
- data/spec/lib/reg_api2/service_spec.rb +17 -17
- data/spec/lib/reg_api2/shop_spec.rb +15 -0
- data/spec/lib/reg_api2/sym_hash_spec.rb +23 -23
- data/spec/lib/reg_api2/user_spec.rb +21 -21
- data/spec/lib/reg_api2/zone_spec.rb +26 -26
- data/spec/spec_helper.rb +4 -1
- metadata +46 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0e71a8b8e931939edc3f25a46d717d705f16c9
|
4
|
+
data.tar.gz: bb0f339992d12f6380f70f192a653ac888a385e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8b82e60de033ebe7faece2f2125cbcc4eccecf14044131a1682913e8e537d83664759470d01443224ff85fcbc66a28a402ca8bfb9eedfe643329195a5baf527
|
7
|
+
data.tar.gz: c3606fa81edd963a8d13254c0f78dc206fd95274b5bd27361e3cf4a9cbfbd128cf462bc048fd51087882e621fa2afbc588b3eb6da69c1919fca64c8f4f71fb5e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -85,14 +85,17 @@ Also console reads `~/.regapi2` configuration file if exists, to assign properti
|
|
85
85
|
|
86
86
|
Please follow these links to view documentation on methods of all known API categories:
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
| Category | Description |
|
89
|
+
| -------- | ----------- |
|
90
|
+
| [common](http://regru.github.io/reg_api2-ruby/RegApi2/Common.html) | Common ops |
|
91
|
+
| [domain](http://regru.github.io/reg_api2-ruby/RegApi2/Domain.html) | Domain registration etc. |
|
92
|
+
| [user](http://regru.github.io/reg_api2-ruby/RegApi2/User.html) | User creation etc. |
|
93
|
+
| [service](http://regru.github.io/reg_api2-ruby/RegApi2/Service.html) | Generic service ops |
|
94
|
+
| [bill](http://regru.github.io/reg_api2-ruby/RegApi2/Bill.html) | Billing |
|
95
|
+
| [folder](http://regru.github.io/reg_api2-ruby/RegApi2/Folder.html) | Folders for services including domains |
|
96
|
+
| [zone](http://regru.github.io/reg_api2-ruby/RegApi2/Zone.html) | Domain zone resource records (DNS) |
|
97
|
+
| [hosting](http://regru.github.io/reg_api2-ruby/RegApi2/Hosting.html) | Jelastic hosting ops at now |
|
98
|
+
| [shop](http://regru.github.io/reg_api2-ruby/RegApi2/Shop.html) | Domain Shop management functions |
|
96
99
|
|
97
100
|
## Recommendations for effective use of REG.API
|
98
101
|
|
@@ -177,7 +180,7 @@ Identification by numeric service identifiers is the most reliable and quick met
|
|
177
180
|
| | **Service identification by parent service ID, service type or subtype** |
|
178
181
|
| uplink_service_id | ID of the parent service with which the required service is associated. |
|
179
182
|
| servtype | Service type. For example, «srv_hosting_ispmgr» for hosting or «srv_webfwd» for the web-forwarding service. |
|
180
|
-
| subtype | Service subtype. For example, «pro» for the ISP Manager Pro license. |
|
183
|
+
| subtype | Service subtype. For example, «pro» for the ISP Manager Pro license. |
|
181
184
|
|
182
185
|
### Service list identification parameters
|
183
186
|
|
@@ -278,7 +281,7 @@ Error code from REG.API raised by client as exception of {RegApi2::ApiError} cla
|
|
278
281
|
|
279
282
|
## Documentation
|
280
283
|
|
281
|
-
Actual documentation available at https://www.reg.com/support/help/
|
284
|
+
Actual documentation available at https://www.reg.com/support/help/api2
|
282
285
|
|
283
286
|
For developers: Ruby client documentation can be accessed as:
|
284
287
|
|
data/lib/reg_api2/domain.rb
CHANGED
@@ -50,9 +50,18 @@ module RegApi2
|
|
50
50
|
|
51
51
|
# @!method get_deleted(opts = {})
|
52
52
|
# Get a list of deleted domains. The function is similar to the [Deleted Domains](https://www.reg.com/domain/new/freeing_domains) page.
|
53
|
+
# Maximum returned elements in list equals to 50000.
|
53
54
|
# @param [Hash] opts Options.
|
54
55
|
# @note Accessibility: partners
|
55
56
|
# @note Support of service lists: no
|
57
|
+
# @example Typical usage
|
58
|
+
# RegApi2.domain.get_deleted(
|
59
|
+
# tlds: 'ru',
|
60
|
+
# deleted_from: '2013-10-01',
|
61
|
+
# deleted_to: '2013-11-01',
|
62
|
+
# min_pr: 2,
|
63
|
+
# min_cy: 1
|
64
|
+
# )
|
56
65
|
define :get_deleted, field: :domains
|
57
66
|
|
58
67
|
# @!method check(opts = {})
|
data/lib/reg_api2/service.rb
CHANGED
@@ -288,7 +288,10 @@ module RegApi2
|
|
288
288
|
# @!method refill(opts = {})
|
289
289
|
# You can use this function to refill balance of you service. Only Jelastic (srv_jelastic) is supported at the moment.
|
290
290
|
# @param opts Options.
|
291
|
-
# @option opts [
|
291
|
+
# @option opts [Fixnum] service_id Service id to be refilled.
|
292
|
+
# @option opts [Number] amount Amount of the invoice.
|
293
|
+
# @option opts [String] currency Invoice currency (RUR, USD, EUR, UAH).
|
294
|
+
# @option opts [Boolean] ok_if_no_money Enable to create bill when not enough funds to complete the operation. In this case requested operation is stored in the system, however it will be processed after submitting "change payment method" request via web interface. Return error if this flag not set and not enough funds to complete the operation.
|
292
295
|
# @return [Hash(service_id, bill_id etc.)]
|
293
296
|
# @note Accessibility: clients
|
294
297
|
# @note Support of service lists: no
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module RegApi2
|
4
|
+
# REG.API shop category
|
5
|
+
module Shop
|
6
|
+
|
7
|
+
include RegApi2::Builder
|
8
|
+
|
9
|
+
category :shop
|
10
|
+
|
11
|
+
# @!method nop
|
12
|
+
# @param opts Opts
|
13
|
+
# @option opts [String] :dname Domain name.
|
14
|
+
# For testing purposes. Also, with the help of this function you can check accessibility of a lot and get its ID. For this, pass username+password+dname.
|
15
|
+
# @return [String] lot identifier or nil.
|
16
|
+
define :nop
|
17
|
+
|
18
|
+
# @!method add_lot
|
19
|
+
# @param opts Opts
|
20
|
+
# adding lot/lots.
|
21
|
+
# @return [void] Nothing.
|
22
|
+
define :add_lot
|
23
|
+
|
24
|
+
# @!method add_lot
|
25
|
+
# @param opts Opts
|
26
|
+
# Update lot/lots.
|
27
|
+
# @return [void] Nothing.
|
28
|
+
define :update_lot
|
29
|
+
|
30
|
+
# @!method delete_lot
|
31
|
+
# @param opts Opts
|
32
|
+
# @option opts [String] :dname Domain list.
|
33
|
+
# delete lot/lots.
|
34
|
+
# @return [void] Nothing.
|
35
|
+
define :delete_lot, required: { dname: {} }
|
36
|
+
|
37
|
+
# @!method get_info
|
38
|
+
# @param opts Opts
|
39
|
+
# @option opts [String] :dname Domain list.
|
40
|
+
# obtain information on the lot.
|
41
|
+
# @return [Hash] Lots data.
|
42
|
+
define :get_info, required: { dname: {} }
|
43
|
+
|
44
|
+
# @!method get_lot_list
|
45
|
+
# @param opts Opts
|
46
|
+
# @option opts [Boolean] :show_my_lots "Only my items" flag.
|
47
|
+
# @option opts [Fixnum] :pg what page to show, by default - 0.
|
48
|
+
# @option opts [Fixnum] :itemsonpage how many items per page, by default - 25, possible values: 25, 50, 100, 200, 500.
|
49
|
+
# getting a list of lots.
|
50
|
+
# @return [Hash] Lots data.
|
51
|
+
define :get_lot_list
|
52
|
+
|
53
|
+
# @!method get_category_list
|
54
|
+
# @param opts Opts
|
55
|
+
# getting a list of categories.
|
56
|
+
# @return [Array] List of categories.
|
57
|
+
define :get_category_list, field: :category_list
|
58
|
+
|
59
|
+
# @!method get_category_list
|
60
|
+
# @param opts Opts
|
61
|
+
# @option opts [Fixnum] :limit the number of tags, optional, default 10, maximum 50.
|
62
|
+
# getting a list of popular tags.
|
63
|
+
# @return [Array] List of tags.
|
64
|
+
define :get_suggested_tags, field: :tags
|
65
|
+
|
66
|
+
extend self
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
data/lib/reg_api2/version.rb
CHANGED
data/lib/reg_api2.rb
CHANGED
@@ -19,6 +19,7 @@ require 'reg_api2/bill'
|
|
19
19
|
require 'reg_api2/folder'
|
20
20
|
require 'reg_api2/zone'
|
21
21
|
require 'reg_api2/hosting'
|
22
|
+
require 'reg_api2/shop'
|
22
23
|
|
23
24
|
# Provides r/w settings for API connection:
|
24
25
|
#
|
@@ -38,6 +39,7 @@ require 'reg_api2/hosting'
|
|
38
39
|
# * {RegApi2.folder} API category implemented as {RegApi2::Folder} methods.
|
39
40
|
# * {RegApi2.zone} API category implemented as {RegApi2::Zone} methods.
|
40
41
|
# * {RegApi2.hosting} API category implemented as {RegApi2::Hosting} methods.
|
42
|
+
# * {RegApi2.shop} API category implemented as {RegApi2::Shop} methods.
|
41
43
|
#
|
42
44
|
# Provides dump hooks:
|
43
45
|
#
|
@@ -67,7 +69,7 @@ module RegApi2
|
|
67
69
|
module_function :common
|
68
70
|
|
69
71
|
# Shortcut for {RegApi2::Domain} methods.
|
70
|
-
# @return [Module] {RegApi2::Domain}
|
72
|
+
# @return [Module] {RegApi2::Domain}
|
71
73
|
# @api Shortcuts
|
72
74
|
def domain; RegApi2::Domain; end
|
73
75
|
module_function :domain
|
@@ -108,6 +110,12 @@ module RegApi2
|
|
108
110
|
def hosting; RegApi2::Hosting; end
|
109
111
|
module_function :hosting
|
110
112
|
|
113
|
+
# Shortcut for {RegApi2::Shop} methods.
|
114
|
+
# @return [Module] {RegApi2::Shop}
|
115
|
+
# @api Shortcuts
|
116
|
+
def shop; RegApi2::Shop; end
|
117
|
+
module_function :shop
|
118
|
+
|
111
119
|
class << self
|
112
120
|
# @!attribute [rw] username
|
113
121
|
# @return [String] User name (`test` by default).
|
data/reg.api2.gemspec
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "yajl-ruby", "~> 1.0"
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec", "~>
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "rspec-collection_matchers", "~> 1.0"
|
26
27
|
spec.add_development_dependency "faker"
|
27
28
|
spec.add_development_dependency "machinist"
|
28
29
|
spec.add_development_dependency "yard", "~> 0.8"
|
@@ -6,64 +6,64 @@ describe RegApi2::Bill do
|
|
6
6
|
|
7
7
|
describe :nop do
|
8
8
|
it "should raise nothing" do
|
9
|
-
|
9
|
+
expect { bill.nop }.not_to raise_error
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should return nil" do
|
13
|
-
bill.nop.
|
13
|
+
expect(bill.nop).to be_nil
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return bill if specified" do
|
17
|
-
bill.nop(bill_id: 12345).
|
17
|
+
expect(bill.nop(bill_id: 12345)).to have_exactly(1).bill
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return bills if specified" do
|
21
|
-
bill.nop(bills: [ 12345, 12346 ]).
|
22
|
-
end
|
21
|
+
expect(bill.nop(bills: [ 12345, 12346 ])).to have_exactly(2).bills
|
22
|
+
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe :get_not_payed do
|
26
26
|
it "should raise nothing" do
|
27
|
-
|
27
|
+
expect { bill.get_not_payed }.not_to raise_error
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should return something real" do
|
31
|
-
bill.get_not_payed.
|
31
|
+
expect(bill.get_not_payed).to have_exactly(1).bill
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe :get_for_period do
|
36
36
|
it "should raise ContractError without dates" do
|
37
|
-
|
37
|
+
expect { bill.get_for_period }.to raise_error RegApi2::ContractError
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should return something real" do
|
41
|
-
bill.get_for_period(
|
41
|
+
expect(bill.get_for_period(
|
42
42
|
start_date: Date.new(2000, 1, 1),
|
43
43
|
end_date: Date.new(2015, 1, 1)
|
44
|
-
).
|
44
|
+
)).to have_exactly(1).bill
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe :change_pay_type do
|
49
49
|
it "should raise if no currency given" do
|
50
|
-
|
51
|
-
pay_type: :prepay,
|
52
|
-
bills: [ 123456 ]
|
53
|
-
) }.
|
50
|
+
expect { bill.change_pay_type(
|
51
|
+
pay_type: :prepay,
|
52
|
+
bills: [ 123456 ]
|
53
|
+
) }.to raise_error RegApi2::ContractError
|
54
54
|
end
|
55
55
|
it "should raise if no pay_type given" do
|
56
|
-
|
57
|
-
currency: :RUR,
|
56
|
+
expect { bill.change_pay_type(
|
57
|
+
currency: :RUR,
|
58
58
|
bills: [ 123456 ]
|
59
|
-
) }.
|
59
|
+
) }.to raise_error RegApi2::ContractError
|
60
60
|
end
|
61
61
|
it "should raise nothing if ok" do
|
62
|
-
bill.change_pay_type(
|
62
|
+
expect(bill.change_pay_type(
|
63
63
|
pay_type: :prepay,
|
64
64
|
currency: :RUR,
|
65
65
|
bills: [ 123456 ]
|
66
|
-
).
|
66
|
+
)).to have_exactly(1).bill
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -72,9 +72,9 @@ describe RegApi2::Bill do
|
|
72
72
|
ans = bill.delete(
|
73
73
|
bills: [ { bill_id: 12345 }, { bill_id: 12346 }, { bill_id: 12347 } ]
|
74
74
|
)
|
75
|
-
ans.map { |b| b.bill_id }.
|
76
|
-
ans.each { |b| b.result.
|
77
|
-
ans.each { |b| b.status.
|
75
|
+
expect(ans.map { |b| b.bill_id }).to eq([ 12345, 12346, 12347 ])
|
76
|
+
ans.each { |b| expect(b.result).to eq('success') }
|
77
|
+
ans.each { |b| expect(b.status).to eq('deleted') }
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -5,34 +5,34 @@ describe RegApi2::Common do
|
|
5
5
|
|
6
6
|
describe :nop do
|
7
7
|
it "should raise nothing" do
|
8
|
-
|
8
|
+
expect { common.nop }.not_to raise_error
|
9
9
|
end
|
10
10
|
it "should return login" do
|
11
|
-
common.nop.login.
|
11
|
+
expect(common.nop.login).to eq(RegApi2.username)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe :reseller_nop do
|
16
16
|
it "should raise nothing" do
|
17
|
-
|
17
|
+
expect { common.reseller_nop }.not_to raise_error
|
18
18
|
end
|
19
19
|
it "should return login" do
|
20
|
-
common.reseller_nop.login.
|
20
|
+
expect(common.reseller_nop.login).to eq(RegApi2.username)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe :get_user_id do
|
25
25
|
it "should raise nothing" do
|
26
|
-
|
26
|
+
expect { common.get_user_id }.not_to raise_error
|
27
27
|
end
|
28
28
|
it "should return user id" do
|
29
|
-
common.get_user_id.
|
29
|
+
expect(common.get_user_id).to be_kind_of(Fixnum)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe :get_service_id do
|
34
34
|
it "should raise nothing" do
|
35
|
-
|
35
|
+
expect { common.get_service_id(service_id: 123456) }.not_to raise_error
|
36
36
|
end
|
37
37
|
it "should return user id" do
|
38
38
|
common.get_service_id(service_id: 123456) == 123456
|
@@ -5,7 +5,7 @@ describe RegApi2::Domain do
|
|
5
5
|
|
6
6
|
describe :nop do
|
7
7
|
it "should raise nothing" do
|
8
|
-
|
8
|
+
expect { domain.nop }.not_to raise_error
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should return service id if domain exist"
|
@@ -19,15 +19,28 @@ describe RegApi2::Domain do
|
|
19
19
|
show_update_data: true,
|
20
20
|
currency: :USD
|
21
21
|
)
|
22
|
-
prices.
|
23
|
-
prices.currency.
|
22
|
+
expect(prices).to have_key(:price_group)
|
23
|
+
expect(prices.currency).to eq('USD')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe :get_suggest do
|
28
28
|
it "should return suggestions" do
|
29
29
|
ans = domain.get_suggest word: 'house', additional_word: 'new', use_hyphen: false, tlds: [ :ru ]
|
30
|
-
ans.
|
30
|
+
expect(ans).to be_kind_of(Array)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe :get_deleted do
|
35
|
+
it "should return deleted domains" do
|
36
|
+
ans = domain.get_deleted(
|
37
|
+
tlds: 'ru',
|
38
|
+
deleted_from: '2013-10-01',
|
39
|
+
deleted_to: '2013-11-01',
|
40
|
+
min_pr: 2,
|
41
|
+
min_cy: 1
|
42
|
+
)
|
43
|
+
expect(ans).to be_kind_of(Array)
|
31
44
|
end
|
32
45
|
end
|
33
46
|
end
|
@@ -8,15 +8,15 @@ describe Testplate do
|
|
8
8
|
let!(:plate) { Testplate.new(a: 4, b: 5) }
|
9
9
|
|
10
10
|
it "should be initialized with hash" do
|
11
|
-
plate.a.
|
12
|
-
plate.b.
|
11
|
+
expect(plate.a).to eq(4)
|
12
|
+
expect(plate.b).to eq(5)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should return the hash" do
|
16
|
-
plate.to_hash.
|
16
|
+
expect(plate.to_hash).to eq({ a: 4, b: 5 })
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should return json" do
|
20
|
-
plate.to_json.
|
20
|
+
expect(plate.to_json).to match(/^{.?"a":4/)
|
21
21
|
end
|
22
22
|
end
|
@@ -8,45 +8,45 @@ describe RegApi2::Folder do
|
|
8
8
|
|
9
9
|
describe :nop do
|
10
10
|
it "should raise nothing" do
|
11
|
-
|
11
|
+
expect { folder.nop }.not_to raise_error
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return default folder if no ops set" do
|
15
|
-
folder.nop.
|
15
|
+
expect(folder.nop).to eq(EXAMPLE_FOLDER_DATA)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return folder data if folder_id specified" do
|
19
|
-
folder.nop(folder_id: 12345).
|
19
|
+
expect(folder.nop(folder_id: 12345)).to eq(EXAMPLE_FOLDER_DATA)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should return folder data if test_folder_name specified" do
|
23
|
-
folder.nop(folder_name: "test_folder_name").
|
23
|
+
expect(folder.nop(folder_name: "test_folder_name")).to eq(EXAMPLE_FOLDER_DATA)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe :create do
|
28
28
|
it "should create a folder" do
|
29
|
-
folder.create(folder_name: 'test_folder_name').
|
29
|
+
expect(folder.create(folder_name: 'test_folder_name')).to be_nil
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe :remove do
|
34
34
|
it "should remove a folder by id" do
|
35
|
-
folder.remove(folder_id: 123456).
|
35
|
+
expect(folder.remove(folder_id: 123456)).to be_nil
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should remove a folder by name" do
|
39
|
-
folder.remove(folder_name: 'test_folder_name').
|
39
|
+
expect(folder.remove(folder_name: 'test_folder_name')).to be_nil
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe :rename do
|
44
44
|
it "should rename a folder by id" do
|
45
|
-
folder.rename(folder_id: 123456, new_folder_name: 'new_test_folder_name').
|
45
|
+
expect(folder.rename(folder_id: 123456, new_folder_name: 'new_test_folder_name')).to have_key(:folder_content)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should rename a folder by name" do
|
49
|
-
folder.rename(folder_name: 'test_folder_name', new_folder_name: 'new_test_folder_name').
|
49
|
+
expect(folder.rename(folder_name: 'test_folder_name', new_folder_name: 'new_test_folder_name')).to have_key(:folder_content)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -6,19 +6,19 @@ describe RegApi2::Hosting do
|
|
6
6
|
|
7
7
|
describe :nop do
|
8
8
|
it "should return nil" do
|
9
|
-
hosting.nop.
|
9
|
+
expect(hosting.nop).to be_nil
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe :get_jelastic_refill_url do
|
14
14
|
it "should return \"https://test1.ru\"" do
|
15
|
-
hosting.get_jelastic_refill_url.
|
15
|
+
expect(hosting.get_jelastic_refill_url).to eq("https://test1.ru")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe :set_jelastic_refill_url do
|
20
20
|
it "should return nil on success" do
|
21
|
-
hosting.set_jelastic_refill_url(url: "http://ya.ru/").
|
21
|
+
expect(hosting.set_jelastic_refill_url(url: "http://ya.ru/")).to be_nil
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -12,29 +12,29 @@ describe RegApi2 do
|
|
12
12
|
|
13
13
|
it "should #create_http at first call" do
|
14
14
|
allow(RegApi2).to receive(:create_http).once.and_return(45)
|
15
|
-
RegApi2.http.
|
15
|
+
expect(RegApi2.http).to eq(45)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should not #create_http at next call" do
|
19
19
|
allow(RegApi2).to receive(:create_http).once.and_return(45)
|
20
|
-
RegApi2.http.
|
21
|
-
RegApi2.http.
|
20
|
+
expect(RegApi2.http).to eq(45)
|
21
|
+
expect(RegApi2.http).to eq(45)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe :create_http do
|
26
26
|
it "should create Net::HTTP object" do
|
27
27
|
http = RegApi2.create_http
|
28
|
-
http.
|
29
|
-
http.
|
30
|
-
http.verify_mode.
|
28
|
+
expect(http).to be_kind_of(Net::HTTP)
|
29
|
+
expect(http).to be_use_ssl
|
30
|
+
expect(http.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should use ca_cert_path if exists" do
|
34
34
|
allow(RegApi2).to receive(:ca_cert_path).and_return("file")
|
35
35
|
http = RegApi2.create_http
|
36
|
-
http.verify_mode.
|
37
|
-
http.ca_file.
|
36
|
+
expect(http.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER)
|
37
|
+
expect(http.ca_file).to eq("file")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should use pem with pem_password" do
|
@@ -46,8 +46,8 @@ describe RegApi2 do
|
|
46
46
|
allow(OpenSSL::PKey::RSA).to receive(:new).with("pem", "pem_password").and_return(key)
|
47
47
|
|
48
48
|
http = RegApi2.create_http
|
49
|
-
http.cert.
|
50
|
-
http.key.
|
49
|
+
expect(http.cert).to eq(pem)
|
50
|
+
expect(http.key).to eq(key)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should use pem without pem_password" do
|
@@ -59,20 +59,20 @@ describe RegApi2 do
|
|
59
59
|
allow(OpenSSL::PKey::RSA).to receive(:new).with("pem").and_return(key)
|
60
60
|
|
61
61
|
http = RegApi2.create_http
|
62
|
-
http.cert.
|
63
|
-
http.key.
|
62
|
+
expect(http.cert).to eq(pem)
|
63
|
+
expect(http.key).not_to be_nil
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe :make_action do
|
68
68
|
|
69
69
|
it "should raise ApiError with NO_SUCH_COMMAND code on absent command" do
|
70
|
-
|
70
|
+
expect do
|
71
71
|
RegApi2.make_action(:bad, :command, {}, {})
|
72
|
-
end.
|
73
|
-
|
72
|
+
end.to raise_error RegApi2::ApiError
|
73
|
+
expect do
|
74
74
|
RegApi2.make_action(:bad, :command, {}, {})
|
75
|
-
end.
|
75
|
+
end.to raise_error /NO_SUCH_COMMAND/
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -5,7 +5,7 @@ describe RegApi2::ResultContract do
|
|
5
5
|
|
6
6
|
describe :initialize do
|
7
7
|
it "should assign opts" do
|
8
|
-
contract.opts.
|
8
|
+
expect(contract.opts).to eq({ a: 1, b: 4 })
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -13,18 +13,18 @@ describe RegApi2::ResultContract do
|
|
13
13
|
it "should return handle_answer" do
|
14
14
|
expected = 'OOLOLLO'
|
15
15
|
expect(contract).to receive(:handle_answer).with({}).and_return(expected)
|
16
|
-
contract.handle_result({ "answer" => {} }).
|
16
|
+
expect(contract.handle_result({ "answer" => {} })).to eq(expected)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe :handle_answer do
|
21
21
|
it "should return specified value" do
|
22
|
-
contract.handle_answer("FX").
|
22
|
+
expect(contract.handle_answer("FX")).to eq("FX")
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should return field value if exists" do
|
26
26
|
contract = RegApi2::ResultContract.new(a:1, field: :a)
|
27
|
-
contract.handle_result({ answer: { "a" => "FX" } }).
|
27
|
+
expect(contract.handle_result({ answer: { "a" => "FX" } })).to eq("FX")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -36,23 +36,23 @@ describe RegApi2::ResultContract do
|
|
36
36
|
amount: "15",
|
37
37
|
text: "2323"
|
38
38
|
})
|
39
|
-
ans.
|
39
|
+
expect(ans).to eq({
|
40
40
|
active_domains_cnt: 6,
|
41
41
|
success: false,
|
42
42
|
amount: 15.0,
|
43
43
|
text: "2323"
|
44
|
-
}
|
44
|
+
})
|
45
45
|
ans = contract.convert({
|
46
46
|
success: "1",
|
47
47
|
})
|
48
|
-
ans.
|
48
|
+
expect(ans).to eq({
|
49
49
|
success: true,
|
50
|
-
}
|
50
|
+
})
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should proceed arrays too" do
|
54
54
|
ans = contract.convert([ 1, 2, [ 1 ], { amount: "4543" } ])
|
55
|
-
ans.
|
55
|
+
expect(ans).to eq([ 1, 2, [ 1 ], { amount: 4543.0} ])
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|