reg.api2 0.0.12 → 0.0.14

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.
@@ -12,72 +12,72 @@ describe RegApi2::Service do
12
12
  { service_id: "22bug22" },
13
13
  { surprise: "surprise.ru" }
14
14
  ])
15
- ans.map do |rec|
15
+ expect(ans.map do |rec|
16
16
  rec.result == 'success' ? rec.dname : rec.error_code
17
- end.sort.should == %w[ INVALID_SERVICE_ID NO_DOMAIN test.ru test.su test12347.ru ]
17
+ end.sort).to eq(%w[ INVALID_SERVICE_ID NO_DOMAIN test.ru test.su test12347.ru ])
18
18
  end
19
19
  end
20
20
 
21
21
  describe :get_prices do
22
22
  it "should return prices" do
23
23
  ans = service.get_prices show_renew_data: true
24
- ans.should have_key :prices
24
+ expect(ans).to have_key :prices
25
25
  end
26
26
  end
27
27
 
28
28
  describe :get_servtype_details do
29
29
  it "should return service type details" do
30
30
  ans = service.get_servtype_details servtype: :srv_hosting_ispmgr
31
- ans.first.should have_key :commonname
31
+ expect(ans.first).to have_key :commonname
32
32
  end
33
33
  end
34
34
 
35
35
  describe :create do
36
36
  it "should create srv_hosting_ispmgr service" do
37
37
  ans = service.create dname: 'qqq.ru', servtype: :srv_hosting_ispmgr, period: 1, plan: 'Host-2-1209'
38
- ans.descr.should =~ /srv_hosting_ispmgr.+ordered/
38
+ expect(ans.descr).to match(/srv_hosting_ispmgr.+ordered/)
39
39
  end
40
40
  end
41
41
 
42
42
  describe :delete do
43
43
  it "should remove srv_hosting_ispmgr service" do
44
44
  ans = service.delete domain_name: 'test.ru', servtype: :srv_hosting_ispmgr
45
- ans.should be_nil
45
+ expect(ans).to be_nil
46
46
  end
47
47
  end
48
48
 
49
49
  describe :get_list do
50
50
  it "should get list of domains" do
51
51
  ans = service.get_list servtype: :domain
52
- ans.should be_kind_of Array
53
- ans.map(&:servtype).uniq.should == [ "domain"]
54
- ans.map(&:service_id).each { |id| id.should be_kind_of Fixnum }
52
+ expect(ans).to be_kind_of Array
53
+ expect(ans.map(&:servtype).uniq).to eq([ "domain"])
54
+ ans.map(&:service_id).each { |id| expect(id).to be_kind_of Fixnum }
55
55
  end
56
56
  end
57
57
 
58
58
  describe :get_dedicated_server_list do
59
59
  it "should get list of dedicated servers" do
60
60
  ans = service.get_dedicated_server_list
61
- ans.should be_kind_of Array
62
- ans.map(&:server_id).each { |id| id.should be_kind_of Fixnum }
61
+ expect(ans).to be_kind_of Array
62
+ ans.map(&:server_id).each { |id| expect(id).to be_kind_of Fixnum }
63
63
  end
64
64
  end
65
65
 
66
66
  describe :get_bills do
67
67
  it "should get list of services and bills" do
68
68
  ans = service.get_bills dname: "qqq.ru"
69
- ans.services.should be_kind_of Array
70
- ans.bills.should be_nil
69
+ expect(ans.services).to be_kind_of Array
70
+ expect(ans.bills).to be_nil
71
71
  end
72
72
  end
73
73
 
74
74
  describe :refill do
75
75
  it "should refill by service id" do
76
76
  ans = service.refill service_id: 123456, amount: 10, currency: 'UAH'
77
- ans.pay_notes.should include("success")
78
- ans.pay_type.should == "prepay"
79
- ans.service_id.should == 123456
80
- ans.payment.should > 0
77
+ expect(ans.pay_notes).to include("success")
78
+ expect(ans.pay_type).to eq("prepay")
79
+ expect(ans.service_id).to eq(123456)
80
+ expect(ans.payment).to be > 0
81
81
  end
82
82
  end
83
83
  end
@@ -0,0 +1,15 @@
1
+ # -*- encoding : utf-8 -*-
2
+ describe RegApi2::Shop do
3
+
4
+ include RegApi2
5
+
6
+ describe :nop do
7
+ it "should raise nothing" do
8
+ expect { shop.nop }.not_to raise_error
9
+ end
10
+
11
+ it "should return lot id if domain exist" do
12
+ expect(RegApi2.shop.nop(dname: 'test.ru')).to have_key( 'lot_id' )
13
+ end
14
+ end
15
+ end
@@ -6,76 +6,76 @@ describe RegApi2::SymHash do
6
6
 
7
7
  describe :new do
8
8
  it "should be kind of Hash" do
9
- hash.should be_kind_of(Hash)
9
+ expect(hash).to be_kind_of(Hash)
10
10
  end
11
11
  end
12
12
 
13
13
  describe :method_missing do
14
14
  it "should assign key" do
15
15
  hash.unique_key = "unique"
16
- hash["unique_key"].should == "unique"
16
+ expect(hash["unique_key"]).to eq("unique")
17
17
  end
18
18
 
19
19
  it "should reassign key" do
20
20
  hash["next_key"] = "a"
21
21
  hash.next_key = "b"
22
- hash["next_key"].should == "b"
22
+ expect(hash["next_key"]).to eq("b")
23
23
  end
24
24
 
25
25
  it "should return value" do
26
26
  hash["another_key"] = "f"
27
- hash.another_key.should == "f"
27
+ expect(hash.another_key).to eq("f")
28
28
  end
29
29
 
30
30
  it "should return bool if key ends with ?" do
31
31
  hash.ping = 15
32
- hash.should be_ping
32
+ expect(hash).to be_ping
33
33
  hash.pong = nil
34
- hash.should_not be_pong
34
+ expect(hash).not_to be_pong
35
35
  end
36
36
 
37
37
  it "should return nil unless keypair present" do
38
- hash.absent_key.should be_nil
39
- end
38
+ expect(hash.absent_key).to be_nil
39
+ end
40
40
  end
41
41
 
42
42
  describe :respond_to? do
43
43
  it "should always respond to any method" do
44
- hash.should respond_to(:any_method)
44
+ expect(hash).to respond_to(:any_method)
45
45
  end
46
46
  end
47
47
 
48
48
  describe :include? do
49
49
  it "should be has_key?" do
50
50
  allow(hash).to receive(:has_key?).with("what").and_return(true)
51
- hash.include?("what").should be_true
51
+ expect(hash.include?("what")).to be true
52
52
  end
53
53
  end
54
54
 
55
55
  describe :has_key? do
56
56
  it "should represent symbol keys as strings" do
57
57
  hash["frank"] = 56
58
- hash[:frank].should == 56
59
- hash.should have_key("frank")
60
- hash.should have_key(:frank)
58
+ expect(hash[:frank]).to eq(56)
59
+ expect(hash).to have_key("frank")
60
+ expect(hash).to have_key(:frank)
61
61
 
62
62
  hash[:bravo] = 56
63
- hash["bravo"].should == 56
64
- hash.should have_key("bravo")
65
- hash.should have_key(:bravo)
63
+ expect(hash["bravo"]).to eq(56)
64
+ expect(hash).to have_key("bravo")
65
+ expect(hash).to have_key(:bravo)
66
66
  end
67
67
  end
68
68
 
69
69
  describe "self.from" do
70
70
  it "should deeply clone structures with replacing hashes with SymHash" do
71
71
  res = RegApi2::SymHash.from([{a: 1}, {b: 2}, [ 1, 2, 3 ]])
72
- res.should be_kind_of(Array)
73
- res.should have(3).elements
74
- res.first.should be_kind_of(RegApi2::SymHash)
75
- res[1].should be_kind_of(RegApi2::SymHash)
76
- res.last.should_not be_kind_of(RegApi2::SymHash)
77
- res.last.should be_kind_of(Array)
78
- res.last.should == [ 1, 2 , 3 ]
72
+ expect(res).to be_kind_of(Array)
73
+ expect(res).to have_exactly(3).elements
74
+ expect(res.first).to be_kind_of(RegApi2::SymHash)
75
+ expect(res[1]).to be_kind_of(RegApi2::SymHash)
76
+ expect(res.last).not_to be_kind_of(RegApi2::SymHash)
77
+ expect(res.last).to be_kind_of(Array)
78
+ expect(res.last).to eq([ 1, 2 , 3 ])
79
79
  end
80
80
  end
81
81
  end
@@ -9,44 +9,44 @@ describe RegApi2::User do
9
9
 
10
10
  describe :nop do
11
11
  it "should raise nothing" do
12
- lambda { user.nop }.should_not raise_error
12
+ expect { user.nop }.not_to raise_error
13
13
  end
14
14
 
15
15
  it "should return nil" do
16
- user.nop.should be_nil
16
+ expect(user.nop).to be_nil
17
17
  end
18
18
  end
19
19
 
20
20
  describe :create do
21
21
  it "should raise ContractError unless user_login provided." do
22
- lambda { user.create(FakeUser.make(:bad_login)) }.should raise_error RegApi2::ContractError
23
- lambda { user.create(FakeUser.make(:bad_login)) }.should raise_error /user_login/
22
+ expect { user.create(FakeUser.make(:bad_login)) }.to raise_error RegApi2::ContractError
23
+ expect { user.create(FakeUser.make(:bad_login)) }.to raise_error /user_login/
24
24
  end
25
25
 
26
26
  it "should raise ContractError unless user_password provided." do
27
- lambda { user.create(FakeUser.make(:bad_password)) }.should raise_error RegApi2::ContractError
28
- lambda { user.create(FakeUser.make(:bad_password)) }.should raise_error /user_password/
27
+ expect { user.create(FakeUser.make(:bad_password)) }.to raise_error RegApi2::ContractError
28
+ expect { user.create(FakeUser.make(:bad_password)) }.to raise_error /user_password/
29
29
  end
30
30
 
31
31
  it "should raise ContractError unless user_email provided." do
32
- lambda { user.create(FakeUser.make(:bad_email)) }.should raise_error RegApi2::ContractError
33
- lambda { user.create(FakeUser.make(:bad_email)) }.should raise_error /user_email/
32
+ expect { user.create(FakeUser.make(:bad_email)) }.to raise_error RegApi2::ContractError
33
+ expect { user.create(FakeUser.make(:bad_email)) }.to raise_error /user_email/
34
34
  end
35
35
 
36
36
  it "should raise ContractError unless user_country_code provided." do
37
- lambda { user.create(FakeUser.make(:bad_country_code)) }.should raise_error RegApi2::ContractError
38
- lambda { user.create(FakeUser.make(:bad_country_code)) }.should raise_error /user_country_code/
37
+ expect { user.create(FakeUser.make(:bad_country_code)) }.to raise_error RegApi2::ContractError
38
+ expect { user.create(FakeUser.make(:bad_country_code)) }.to raise_error /user_country_code/
39
39
  end
40
40
 
41
41
  it "should create user with valid data." do
42
- lambda { user.create(FakeUser.make(:good_user)) }.should_not raise_error
43
- user.create(FakeUser.make(:good_user)).should == "777"
42
+ expect { user.create(FakeUser.make(:good_user)) }.not_to raise_error
43
+ expect(user.create(FakeUser.make(:good_user))).to eq("777")
44
44
  end
45
45
  end
46
46
 
47
47
  describe :get_statistics do
48
48
  it "should return user statistics" do
49
- user.get_statistics.keys.sort.should == %w[
49
+ expect(user.get_statistics.keys.sort).to eq(%w[
50
50
  active_domains_cnt
51
51
  active_domains_get_ctrl_cnt
52
52
  balance_total
@@ -54,16 +54,16 @@ describe RegApi2::User do
54
54
  renew_domains_cnt
55
55
  renew_domains_get_ctrl_cnt
56
56
  undelegated_domains_cnt
57
- ]
57
+ ])
58
58
  end
59
59
  end
60
60
 
61
61
  describe :get_balance do
62
62
  it "should return user balance" do
63
- user.get_balance(currency: :USD).keys.sort.should == %w[
63
+ expect(user.get_balance(currency: :USD).keys.sort).to eq(%w[
64
64
  currency
65
65
  prepay
66
- ]
66
+ ])
67
67
  end
68
68
  end
69
69
 
@@ -75,11 +75,11 @@ describe RegApi2::User do
75
75
  currency: :RUR,
76
76
  amount: 1000
77
77
  )
78
- ans.currency.should == 'RUR'
79
- ans.pay_type.should == 'WM'
80
- ans.payment.should == 1000
81
- ans.total_payment.should == 1000
82
- ans.should have_key :wm_invid
78
+ expect(ans.currency).to eq('RUR')
79
+ expect(ans.pay_type).to eq('WM')
80
+ expect(ans.payment).to eq(1000)
81
+ expect(ans.total_payment).to eq(1000)
82
+ expect(ans).to have_key :wm_invid
83
83
  end
84
84
  end
85
85
  end
@@ -8,13 +8,13 @@ describe RegApi2::Zone do
8
8
 
9
9
  describe :nop do
10
10
  it "should raise when no args" do
11
- lambda { zone.nop }.should raise_error
11
+ expect { zone.nop }.to raise_error
12
12
  end
13
13
 
14
14
  it "should return domains if specified" do
15
15
  ans = zone.nop(domains: [ { dname: "test.ru" }, { dname: "test.com" } ])
16
- ans.domains.map(&:servtype).should == [ 'domain', 'domain' ]
17
- ans.domains.map(&:result).should == [ 'success', 'success' ]
16
+ expect(ans.domains.map(&:servtype)).to eq([ 'domain', 'domain' ])
17
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
18
18
  end
19
19
  end
20
20
 
@@ -25,7 +25,7 @@ describe RegApi2::Zone do
25
25
  subdomain: '@',
26
26
  ipaddr: IPAddr.new("111.111.111.111")
27
27
  )
28
- ans.domains.map(&:result).should == [ 'success', 'success' ]
28
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
29
29
  end
30
30
 
31
31
  it "should understood ip addresses as strings too" do
@@ -34,7 +34,7 @@ describe RegApi2::Zone do
34
34
  subdomain: '*',
35
35
  ipaddr: "111.111.111.111"
36
36
  )
37
- ans.domains.map(&:result).should == [ 'success', 'success' ]
37
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
38
38
  end
39
39
  end
40
40
 
@@ -45,7 +45,7 @@ describe RegApi2::Zone do
45
45
  subdomain: '@',
46
46
  ipaddr: IPAddr.new("aa11::a111:11aa:aaa1:aa1a")
47
47
  )
48
- ans.domains.map(&:result).should == [ 'success', 'success' ]
48
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
49
49
  end
50
50
 
51
51
  it "should understood ipv6 addresses as strings too" do
@@ -54,7 +54,7 @@ describe RegApi2::Zone do
54
54
  subdomain: '*',
55
55
  ipaddr: "aa11::a111:11aa:aaa1:aa1a"
56
56
  )
57
- ans.domains.map(&:result).should == [ 'success', 'success' ]
57
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
58
58
  end
59
59
  end
60
60
 
@@ -65,7 +65,7 @@ describe RegApi2::Zone do
65
65
  subdomain: "mail",
66
66
  canonical_name: "mx10.test.ru"
67
67
  )
68
- ans.domains.map(&:result).should == [ 'success', 'success' ]
68
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
69
69
  end
70
70
  end
71
71
 
@@ -76,7 +76,7 @@ describe RegApi2::Zone do
76
76
  subdomain: '@',
77
77
  mail_server: IPAddr.new("111.111.111.111")
78
78
  )
79
- ans.domains.map(&:result).should == [ 'success', 'success' ]
79
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
80
80
  end
81
81
 
82
82
  it "should understood mail servers as domains too" do
@@ -86,7 +86,7 @@ describe RegApi2::Zone do
86
86
  priority: 1,
87
87
  mail_server: "mail"
88
88
  )
89
- ans.domains.map(&:result).should == [ 'success', 'success' ]
89
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
90
90
  end
91
91
  end
92
92
 
@@ -98,18 +98,18 @@ describe RegApi2::Zone do
98
98
  dns_server: "ns.test.ru",
99
99
  record_number: 10
100
100
  )
101
- ans.domains.map(&:result).should == [ 'success', 'success' ]
101
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
102
102
  end
103
103
 
104
104
  it "should check record number" do
105
- lambda do
105
+ expect do
106
106
  zone.add_ns(
107
107
  domains: [ { dname: "test.ru" }, { dname: "test.com" } ],
108
108
  subdomain: 'tt',
109
109
  dns_server: "ns.test.ru",
110
110
  record_number: 'fg'
111
111
  )
112
- end.should raise_error RegApi2::ContractError
112
+ end.to raise_error RegApi2::ContractError
113
113
  end
114
114
  end
115
115
 
@@ -120,7 +120,7 @@ describe RegApi2::Zone do
120
120
  subdomain: 'mail',
121
121
  text: "testmail"
122
122
  )
123
- ans.domains.map(&:result).should == [ 'success', 'success' ]
123
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
124
124
  end
125
125
  end
126
126
 
@@ -133,7 +133,7 @@ describe RegApi2::Zone do
133
133
  port: 5060,
134
134
  target: "sip.test.ru"
135
135
  )
136
- ans.domains.map(&:result).should == [ 'success', 'success' ]
136
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
137
137
  end
138
138
  end
139
139
 
@@ -142,8 +142,8 @@ describe RegApi2::Zone do
142
142
  ans = zone.get_resource_records(
143
143
  domains: [ { dname: "test.ru" }, { dname: "test.com" } ]
144
144
  )
145
- ans.domains.map(&:result).should == [ 'success', 'success' ]
146
- ans.domains.map(&:rrs).should be_kind_of(Array)
145
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
146
+ expect(ans.domains.map(&:rrs)).to be_kind_of(Array)
147
147
  end
148
148
  end
149
149
 
@@ -153,8 +153,8 @@ describe RegApi2::Zone do
153
153
  { action: :add_alias, subdomain: "www", ipaddr: "11.22.33.44" },
154
154
  { action: :add_cname, subdomain: "@", canonical_name: "www.test.ru" }
155
155
  ]
156
- ans.domains.map(&:result).should == [ 'success' ]
157
- ans.domains.first.action_list.map(&:result).should == [ 'success', 'success' ]
156
+ expect(ans.domains.map(&:result)).to eq([ 'success' ])
157
+ expect(ans.domains.first.action_list.map(&:result)).to eq([ 'success', 'success' ])
158
158
  end
159
159
  end
160
160
 
@@ -165,7 +165,7 @@ describe RegApi2::Zone do
165
165
  ttl: "1d",
166
166
  minimum_ttl: "4h"
167
167
  )
168
- ans.domains.map(&:result).should == [ 'success', 'success' ]
168
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
169
169
  end
170
170
  end
171
171
 
@@ -174,7 +174,7 @@ describe RegApi2::Zone do
174
174
  ans = zone.tune_forwarding(
175
175
  domains: [ { dname: "test.ru" }, { dname: "test.com" } ],
176
176
  )
177
- ans.domains.map(&:result).should == [ 'success', 'success' ]
177
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
178
178
  end
179
179
  end
180
180
 
@@ -183,7 +183,7 @@ describe RegApi2::Zone do
183
183
  ans = zone.clear_forwarding(
184
184
  domains: [ { dname: "test.ru" }, { dname: "test.com" } ],
185
185
  )
186
- ans.domains.map(&:result).should == [ 'success', 'success' ]
186
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
187
187
  end
188
188
  end
189
189
 
@@ -192,7 +192,7 @@ describe RegApi2::Zone do
192
192
  ans = zone.tune_parking(
193
193
  domains: [ { dname: "test.ru" }, { dname: "test.com" } ],
194
194
  )
195
- ans.domains.map(&:result).should == [ 'success', 'success' ]
195
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
196
196
  end
197
197
  end
198
198
 
@@ -201,7 +201,7 @@ describe RegApi2::Zone do
201
201
  ans = zone.clear_parking(
202
202
  domains: [ { dname: "test.ru" }, { dname: "test.com" } ],
203
203
  )
204
- ans.domains.map(&:result).should == [ 'success', 'success' ]
204
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
205
205
  end
206
206
  end
207
207
 
@@ -213,7 +213,7 @@ describe RegApi2::Zone do
213
213
  content: '111.111.111.111',
214
214
  record_type: :A
215
215
  )
216
- ans.domains.map(&:result).should == [ 'success', 'success' ]
216
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
217
217
  end
218
218
  end
219
219
 
@@ -222,7 +222,7 @@ describe RegApi2::Zone do
222
222
  ans = zone.clear(
223
223
  domains: [ { dname: "test.ru" }, { dname: "test.com" } ],
224
224
  )
225
- ans.domains.map(&:result).should == [ 'success', 'success' ]
225
+ expect(ans.domains.map(&:result)).to eq([ 'success', 'success' ])
226
226
  end
227
227
  end
228
228
  end
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,10 @@ end
15
15
  require 'faker'
16
16
  require 'machinist'
17
17
  require 'rspec/core'
18
+ require 'rspec/collection_matchers'
19
+
20
+ require 'i18n'
21
+ I18n.enforce_available_locales = false
18
22
 
19
23
  require 'reg_api2'
20
24
 
@@ -23,7 +27,6 @@ class RegApi2::Entity::EntityBase
23
27
  end
24
28
 
25
29
  RSpec.configure do |config|
26
- config.treat_symbols_as_metadata_keys_with_true_values = true
27
30
  config.run_all_when_everything_filtered = true
28
31
  config.filter_run :focus
29
32