sms_aero 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +12 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +19 -0
- data/Gemfile +2 -2
- data/lib/sms_aero/models/sms.rb +6 -6
- data/lib/sms_aero/types/future.rb +1 -1
- data/lib/sms_aero/types/password.rb +5 -0
- data/lib/sms_aero.rb +6 -6
- data/sms_aero.gemspec +1 -1
- data/spec/sms_aero/operations/add_blacklist_spec.rb +24 -33
- data/spec/sms_aero/operations/add_group_spec.rb +26 -35
- data/spec/sms_aero/operations/add_phone_spec.rb +72 -58
- data/spec/sms_aero/operations/check_balance_spec.rb +22 -34
- data/spec/sms_aero/operations/check_groups_spec.rb +21 -33
- data/spec/sms_aero/operations/check_senders_spec.rb +24 -33
- data/spec/sms_aero/operations/check_sending_spec.rb +25 -34
- data/spec/sms_aero/operations/check_sign_spec.rb +24 -33
- data/spec/sms_aero/operations/check_status_spec.rb +25 -34
- data/spec/sms_aero/operations/check_tariff_spec.rb +21 -33
- data/spec/sms_aero/operations/delete_group_spec.rb +24 -33
- data/spec/sms_aero/operations/delete_phone_spec.rb +32 -43
- data/spec/sms_aero/operations/send_sms_spec.rb +64 -57
- data/spec/sms_aero/operations/send_to_group_spec.rb +64 -57
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c467f30e3d598212701a014bfd6b9bd0f41848
|
4
|
+
data.tar.gz: 8a4b14ffca904586bae8ebd89bdf306e52e7dc2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 148f114d52e5aa557a884789db3359a727dc9514bb6934146464f905b511abce59c780666ae2ee1957a224dbff62487031208ab86b1ba0befc544d083806ec15
|
7
|
+
data.tar.gz: 8998b13c3a1309f3ef6aaaec87e57828f5a28af1c0a8bab79d3bd7aac2f0cecff08922d67dd610f1af04e8053620ff770d813840836062311c907babe338ee25
|
data/.codeclimate.yml
CHANGED
@@ -4,4 +4,15 @@ engines:
|
|
4
4
|
enabled: true
|
5
5
|
checks:
|
6
6
|
Rubocop/Style/FrozenStringLiteralComment:
|
7
|
-
enabled: false
|
7
|
+
enabled: false
|
8
|
+
Rubocop/Style/Documentation:
|
9
|
+
enabled: false
|
10
|
+
Rubocop/Style/ClassAndModuleChildren:
|
11
|
+
enabled: false
|
12
|
+
Rubocop/Style/SpaceInLambdaLiteral:
|
13
|
+
enabled: false
|
14
|
+
reek:
|
15
|
+
enabled: true
|
16
|
+
ratings:
|
17
|
+
paths:
|
18
|
+
- "lib/**.rb"
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -5,8 +5,27 @@ AllCops:
|
|
5
5
|
StyleGuideCopsOnly: true
|
6
6
|
TargetRubyVersion: 2.3
|
7
7
|
|
8
|
+
Metrics/LineLength:
|
9
|
+
AllowHeredoc: true
|
10
|
+
AllowURI: true
|
11
|
+
URISchemes:
|
12
|
+
- http
|
13
|
+
- https
|
14
|
+
|
8
15
|
Style/Lambda:
|
9
16
|
Enabled: false
|
10
17
|
|
11
18
|
Style/StringLiterals:
|
12
19
|
EnforcedStyle: double_quotes
|
20
|
+
|
21
|
+
Style/FrozenStringLiteralComment:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/ClassAndModuleChildren:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/SpaceInLambdaLiteral:
|
31
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -8,5 +8,5 @@ group :development, :test do
|
|
8
8
|
gem "pry-byebug", platform: :mri
|
9
9
|
end
|
10
10
|
|
11
|
-
gem "evil-client",
|
12
|
-
gem "dry-initializer",
|
11
|
+
gem "evil-client", git: "https://github.com/evilmartians/evil-client"
|
12
|
+
gem "dry-initializer", git: "https://github.com/dry-rb/dry-initializer"
|
data/lib/sms_aero/models/sms.rb
CHANGED
@@ -5,11 +5,11 @@ class SmsAero
|
|
5
5
|
attribute :date, Types::Future, optional: true
|
6
6
|
attribute :digital, Types::Digital, optional: true
|
7
7
|
attribute :type, Types::Channel, default: -> (*) do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
if digital == 1
|
9
|
+
Dry::Initializer::UNDEFINED
|
10
|
+
else
|
11
|
+
2
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/sms_aero.rb
CHANGED
@@ -16,13 +16,13 @@ class SmsAero
|
|
16
16
|
|
17
17
|
settings do
|
18
18
|
option :user, Types::FilledString
|
19
|
-
option :password, Types::
|
19
|
+
option :password, Types::Password
|
20
20
|
option :use_ssl, Types::Form::Bool, default: proc { true }
|
21
21
|
option :use_post, Types::Form::Bool, default: proc { true }
|
22
22
|
end
|
23
23
|
|
24
24
|
base_url do |settings|
|
25
|
-
"http#{
|
25
|
+
"http#{'s' if settings.use_ssl}://gate.smsaero.ru/"
|
26
26
|
end
|
27
27
|
|
28
28
|
operation do |settings|
|
@@ -30,10 +30,10 @@ class SmsAero
|
|
30
30
|
|
31
31
|
http_method(settings.use_post ? :post : :get)
|
32
32
|
|
33
|
-
security do
|
34
|
-
key_auth :user,
|
35
|
-
key_auth :password,
|
36
|
-
key_auth :answer, "json",
|
33
|
+
security do
|
34
|
+
key_auth :user, settings.user, using: :query
|
35
|
+
key_auth :password, settings.password, using: :query
|
36
|
+
key_auth :answer, "json", using: :query
|
37
37
|
end
|
38
38
|
|
39
39
|
responses format: :json do
|
data/sms_aero.gemspec
CHANGED
@@ -8,12 +8,17 @@ RSpec.describe SmsAero, "#add_blacklist" do
|
|
8
8
|
subject { client.add_blacklist(params) }
|
9
9
|
|
10
10
|
context "using ssl via POST:" do
|
11
|
-
let(:
|
12
|
-
|
11
|
+
let(:url) do
|
12
|
+
"https://gate.smsaero.ru/addblacklist?" \
|
13
|
+
"answer=json&" \
|
14
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
15
|
+
"phone=70181324388&" \
|
16
|
+
"user=LOGIN"
|
17
|
+
end
|
13
18
|
|
14
19
|
it "sends a request" do
|
15
20
|
subject
|
16
|
-
expect(a_request(:post,
|
21
|
+
expect(a_request(:post, url)).to have_been_made
|
17
22
|
end
|
18
23
|
|
19
24
|
it "returns success" do
|
@@ -23,50 +28,36 @@ RSpec.describe SmsAero, "#add_blacklist" do
|
|
23
28
|
end
|
24
29
|
|
25
30
|
context "via GET:" do
|
26
|
-
let(:
|
27
|
-
|
31
|
+
let(:url) do
|
32
|
+
"https://gate.smsaero.ru/addblacklist?" \
|
33
|
+
"answer=json&" \
|
34
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
35
|
+
"phone=70181324388&" \
|
36
|
+
"user=LOGIN"
|
37
|
+
end
|
28
38
|
|
29
39
|
before { settings[:use_post] = false }
|
30
40
|
|
31
41
|
it "sends a request" do
|
32
42
|
subject
|
33
|
-
expect(a_request(:get,
|
43
|
+
expect(a_request(:get, url)).to have_been_made
|
34
44
|
end
|
35
45
|
end
|
36
46
|
|
37
47
|
context "not using ssl:" do
|
38
|
-
let(:
|
39
|
-
|
48
|
+
let(:url) do
|
49
|
+
"http://gate.smsaero.ru/addblacklist?" \
|
50
|
+
"answer=json&" \
|
51
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
52
|
+
"phone=70181324388&" \
|
53
|
+
"user=LOGIN"
|
54
|
+
end
|
40
55
|
|
41
56
|
before { settings[:use_ssl] = false }
|
42
57
|
|
43
58
|
it "sends a request via http" do
|
44
59
|
subject
|
45
|
-
expect(a_request(:post,
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "with custom user:" do
|
50
|
-
let(:host) { "https://gate.smsaero.ru/addblacklist" }
|
51
|
-
let(:query) { "answer=json&password=PASSWORD&phone=70181324388&user=USER" }
|
52
|
-
|
53
|
-
before { params[:user] = "USER" }
|
54
|
-
|
55
|
-
it "sends a request" do
|
56
|
-
subject
|
57
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "with custom password:" do
|
62
|
-
let(:host) { "https://gate.smsaero.ru/addblacklist" }
|
63
|
-
let(:query) { "answer=json&password=PSWD&phone=70181324388&user=LOGIN" }
|
64
|
-
|
65
|
-
before { params[:password] = "PSWD" }
|
66
|
-
|
67
|
-
it "sends a request" do
|
68
|
-
subject
|
69
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
60
|
+
expect(a_request(:post, url)).to have_been_made
|
70
61
|
end
|
71
62
|
end
|
72
63
|
|
@@ -8,12 +8,17 @@ RSpec.describe SmsAero, "#add_group" do
|
|
8
8
|
subject { client.add_group(params) }
|
9
9
|
|
10
10
|
context "using ssl via POST:" do
|
11
|
-
let(:
|
12
|
-
|
11
|
+
let(:url) do
|
12
|
+
"https://gate.smsaero.ru/addgroup?" \
|
13
|
+
"answer=json&" \
|
14
|
+
"group=foobar&" \
|
15
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
16
|
+
"user=LOGIN"
|
17
|
+
end
|
13
18
|
|
14
19
|
it "sends a request" do
|
15
20
|
subject
|
16
|
-
expect(a_request(:post,
|
21
|
+
expect(a_request(:post, url)).to have_been_made
|
17
22
|
end
|
18
23
|
|
19
24
|
it "returns success" do
|
@@ -23,50 +28,36 @@ RSpec.describe SmsAero, "#add_group" do
|
|
23
28
|
end
|
24
29
|
|
25
30
|
context "via GET:" do
|
26
|
-
let(:
|
27
|
-
|
31
|
+
let(:url) do
|
32
|
+
"https://gate.smsaero.ru/addgroup?" \
|
33
|
+
"answer=json&" \
|
34
|
+
"group=foobar&" \
|
35
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
36
|
+
"user=LOGIN"
|
37
|
+
end
|
28
38
|
|
29
39
|
before { settings[:use_post] = false }
|
30
40
|
|
31
41
|
it "sends a request" do
|
32
42
|
subject
|
33
|
-
expect(a_request(:get,
|
43
|
+
expect(a_request(:get, url)).to have_been_made
|
34
44
|
end
|
35
45
|
end
|
36
46
|
|
37
47
|
context "not using ssl:" do
|
38
|
-
let(:
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
subject
|
45
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "with custom user:" do
|
50
|
-
let(:host) { "https://gate.smsaero.ru/addgroup" }
|
51
|
-
let(:query) { "answer=json&group=foobar&password=PASSWORD&user=USER" }
|
52
|
-
|
53
|
-
before { params[:user] = "USER" }
|
54
|
-
|
55
|
-
it "sends a request" do
|
56
|
-
subject
|
57
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
48
|
+
let(:url) do
|
49
|
+
"http://gate.smsaero.ru/addgroup?" \
|
50
|
+
"answer=json&" \
|
51
|
+
"group=foobar&" \
|
52
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
53
|
+
"user=LOGIN"
|
58
54
|
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "with custom password:" do
|
62
|
-
let(:host) { "https://gate.smsaero.ru/addgroup" }
|
63
|
-
let(:query) { "answer=json&group=foobar&password=PSWD&user=LOGIN" }
|
64
55
|
|
65
|
-
before {
|
56
|
+
before { settings[:use_ssl] = false }
|
66
57
|
|
67
|
-
it "
|
68
|
-
subject
|
69
|
-
expect(
|
58
|
+
it "returns success" do
|
59
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
60
|
+
expect(subject.result).to eq "accepted"
|
70
61
|
end
|
71
62
|
end
|
72
63
|
|
@@ -8,12 +8,17 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
8
8
|
subject { client.add_phone(params) }
|
9
9
|
|
10
10
|
context "using ssl via POST:" do
|
11
|
-
let(:
|
12
|
-
|
11
|
+
let(:url) do
|
12
|
+
"https://gate.smsaero.ru/addphone?" \
|
13
|
+
"answer=json&" \
|
14
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
15
|
+
"phone=79093828445&" \
|
16
|
+
"user=LOGIN"
|
17
|
+
end
|
13
18
|
|
14
19
|
it "sends a request" do
|
15
20
|
subject
|
16
|
-
expect(a_request(:post,
|
21
|
+
expect(a_request(:post, url)).to have_been_made
|
17
22
|
end
|
18
23
|
|
19
24
|
it "returns success" do
|
@@ -23,50 +28,36 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
23
28
|
end
|
24
29
|
|
25
30
|
context "via GET:" do
|
26
|
-
let(:
|
27
|
-
|
31
|
+
let(:url) do
|
32
|
+
"https://gate.smsaero.ru/addphone?" \
|
33
|
+
"answer=json&" \
|
34
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
35
|
+
"phone=79093828445&" \
|
36
|
+
"user=LOGIN"
|
37
|
+
end
|
28
38
|
|
29
39
|
before { settings[:use_post] = false }
|
30
40
|
|
31
41
|
it "sends a request" do
|
32
42
|
subject
|
33
|
-
expect(a_request(:get,
|
43
|
+
expect(a_request(:get, url)).to have_been_made
|
34
44
|
end
|
35
45
|
end
|
36
46
|
|
37
47
|
context "not using ssl:" do
|
38
|
-
let(:
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
subject
|
45
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
48
|
+
let(:url) do
|
49
|
+
"http://gate.smsaero.ru/addphone?" \
|
50
|
+
"answer=json&" \
|
51
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
52
|
+
"phone=79093828445&" \
|
53
|
+
"user=LOGIN"
|
46
54
|
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "with custom user:" do
|
50
|
-
let(:host) { "https://gate.smsaero.ru/addphone" }
|
51
|
-
let(:query) { "answer=json&password=PASSWORD&phone=79093828445&user=USER" }
|
52
55
|
|
53
|
-
before {
|
54
|
-
|
55
|
-
it "sends a request" do
|
56
|
-
subject
|
57
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "with custom password:" do
|
62
|
-
let(:host) { "https://gate.smsaero.ru/addphone" }
|
63
|
-
let(:query) { "answer=json&password=PSWD&phone=79093828445&user=LOGIN" }
|
64
|
-
|
65
|
-
before { params[:password] = "PSWD" }
|
56
|
+
before { settings[:use_ssl] = false }
|
66
57
|
|
67
58
|
it "sends a request" do
|
68
59
|
subject
|
69
|
-
expect(a_request(:post,
|
60
|
+
expect(a_request(:post, url)).to have_been_made
|
70
61
|
end
|
71
62
|
end
|
72
63
|
|
@@ -87,16 +78,20 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
87
78
|
end
|
88
79
|
|
89
80
|
context "with valid fname:" do
|
90
|
-
let(:
|
91
|
-
|
92
|
-
"answer=json&
|
81
|
+
let(:url) do
|
82
|
+
"https://gate.smsaero.ru/addphone?" \
|
83
|
+
"answer=json&" \
|
84
|
+
"fname=joe&" \
|
85
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
86
|
+
"phone=79093828445&" \
|
87
|
+
"user=LOGIN"
|
93
88
|
end
|
94
89
|
|
95
90
|
before { params[:fname] = "joe" }
|
96
91
|
|
97
92
|
it "sends a request" do
|
98
93
|
subject
|
99
|
-
expect(a_request(:post,
|
94
|
+
expect(a_request(:post, url)).to have_been_made
|
100
95
|
end
|
101
96
|
end
|
102
97
|
|
@@ -109,16 +104,20 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
109
104
|
end
|
110
105
|
|
111
106
|
context "with valid sname:" do
|
112
|
-
let(:
|
113
|
-
|
114
|
-
"answer=json&
|
107
|
+
let(:url) do
|
108
|
+
"https://gate.smsaero.ru/addphone?" \
|
109
|
+
"answer=json&" \
|
110
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
111
|
+
"phone=79093828445&" \
|
112
|
+
"sname=joe&" \
|
113
|
+
"user=LOGIN"
|
115
114
|
end
|
116
115
|
|
117
116
|
before { params[:sname] = "joe" }
|
118
117
|
|
119
118
|
it "sends a request" do
|
120
119
|
subject
|
121
|
-
expect(a_request(:post,
|
120
|
+
expect(a_request(:post, url)).to have_been_made
|
122
121
|
end
|
123
122
|
end
|
124
123
|
|
@@ -131,16 +130,20 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
131
130
|
end
|
132
131
|
|
133
132
|
context "with valid lname:" do
|
134
|
-
let(:
|
135
|
-
|
136
|
-
"answer=json&
|
133
|
+
let(:url) do
|
134
|
+
"https://gate.smsaero.ru/addphone?" \
|
135
|
+
"answer=json&" \
|
136
|
+
"lname=smith&" \
|
137
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
138
|
+
"phone=79093828445&" \
|
139
|
+
"user=LOGIN"
|
137
140
|
end
|
138
141
|
|
139
142
|
before { params[:lname] = "smith" }
|
140
143
|
|
141
144
|
it "sends a request" do
|
142
145
|
subject
|
143
|
-
expect(a_request(:post,
|
146
|
+
expect(a_request(:post, url)).to have_been_made
|
144
147
|
end
|
145
148
|
end
|
146
149
|
|
@@ -153,16 +156,20 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
153
156
|
end
|
154
157
|
|
155
158
|
context "with valid group:" do
|
156
|
-
let(:
|
157
|
-
|
158
|
-
"answer=json&
|
159
|
+
let(:url) do
|
160
|
+
"https://gate.smsaero.ru/addphone?" \
|
161
|
+
"answer=json&" \
|
162
|
+
"group=qux&" \
|
163
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
164
|
+
"phone=79093828445&" \
|
165
|
+
"user=LOGIN"
|
159
166
|
end
|
160
167
|
|
161
168
|
before { params[:group] = "qux" }
|
162
169
|
|
163
170
|
it "sends a request" do
|
164
171
|
subject
|
165
|
-
expect(a_request(:post,
|
172
|
+
expect(a_request(:post, url)).to have_been_made
|
166
173
|
end
|
167
174
|
end
|
168
175
|
|
@@ -175,16 +182,20 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
175
182
|
end
|
176
183
|
|
177
184
|
context "with valid param:" do
|
178
|
-
let(:
|
179
|
-
|
180
|
-
"answer=json&
|
185
|
+
let(:url) do
|
186
|
+
"https://gate.smsaero.ru/addphone?" \
|
187
|
+
"answer=json&" \
|
188
|
+
"param=qux&" \
|
189
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
190
|
+
"phone=79093828445&" \
|
191
|
+
"user=LOGIN"
|
181
192
|
end
|
182
193
|
|
183
194
|
before { params[:param] = "qux" }
|
184
195
|
|
185
196
|
it "sends a request" do
|
186
197
|
subject
|
187
|
-
expect(a_request(:post,
|
198
|
+
expect(a_request(:post, url)).to have_been_made
|
188
199
|
end
|
189
200
|
end
|
190
201
|
|
@@ -197,17 +208,20 @@ RSpec.describe SmsAero, "#add_phone" do
|
|
197
208
|
end
|
198
209
|
|
199
210
|
context "with valid bday:" do
|
200
|
-
let(:
|
201
|
-
|
202
|
-
"answer=json&
|
203
|
-
"
|
211
|
+
let(:url) do
|
212
|
+
"https://gate.smsaero.ru/addphone?" \
|
213
|
+
"answer=json&" \
|
214
|
+
"bday=1901-08-17&" \
|
215
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
216
|
+
"phone=79093828445&" \
|
217
|
+
"user=LOGIN"
|
204
218
|
end
|
205
219
|
|
206
220
|
before { params[:bday] = Date.parse("1901-08-17") }
|
207
221
|
|
208
222
|
it "sends a request" do
|
209
223
|
subject
|
210
|
-
expect(a_request(:post,
|
224
|
+
expect(a_request(:post, url)).to have_been_made
|
211
225
|
end
|
212
226
|
end
|
213
227
|
|
@@ -8,12 +8,16 @@ RSpec.describe SmsAero, "#check_balance" do
|
|
8
8
|
subject { client.check_balance(params) }
|
9
9
|
|
10
10
|
context "using ssl via POST:" do
|
11
|
-
let(:
|
12
|
-
|
11
|
+
let(:url) do
|
12
|
+
"https://gate.smsaero.ru/balance?" \
|
13
|
+
"answer=json&" \
|
14
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
15
|
+
"user=LOGIN"
|
16
|
+
end
|
13
17
|
|
14
18
|
it "sends a request" do
|
15
19
|
subject
|
16
|
-
expect(a_request(:post,
|
20
|
+
expect(a_request(:post, url)).to have_been_made
|
17
21
|
end
|
18
22
|
|
19
23
|
it "returns success" do
|
@@ -25,50 +29,34 @@ RSpec.describe SmsAero, "#check_balance" do
|
|
25
29
|
end
|
26
30
|
|
27
31
|
context "via GET:" do
|
28
|
-
let(:
|
29
|
-
|
32
|
+
let(:url) do
|
33
|
+
"https://gate.smsaero.ru/balance?" \
|
34
|
+
"answer=json&" \
|
35
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
36
|
+
"user=LOGIN"
|
37
|
+
end
|
30
38
|
|
31
39
|
before { settings[:use_post] = false }
|
32
40
|
|
33
41
|
it "sends a request" do
|
34
42
|
subject
|
35
|
-
expect(a_request(:get,
|
43
|
+
expect(a_request(:get, url)).to have_been_made
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
39
47
|
context "not using ssl:" do
|
40
|
-
let(:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
it "sends a request" do
|
46
|
-
subject
|
47
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
48
|
+
let(:url) do
|
49
|
+
"http://gate.smsaero.ru/balance?" \
|
50
|
+
"answer=json&" \
|
51
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&" \
|
52
|
+
"user=LOGIN"
|
48
53
|
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "with custom user:" do
|
52
|
-
let(:host) { "https://gate.smsaero.ru/balance" }
|
53
|
-
let(:query) { "answer=json&password=PASSWORD&user=USER" }
|
54
54
|
|
55
|
-
before {
|
56
|
-
|
57
|
-
it "sends a request" do
|
58
|
-
subject
|
59
|
-
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "with custom password:" do
|
64
|
-
let(:host) { "https://gate.smsaero.ru/balance" }
|
65
|
-
let(:query) { "answer=json&password=PSWD&user=LOGIN" }
|
66
|
-
|
67
|
-
before { params[:password] = "PSWD" }
|
55
|
+
before { settings[:use_ssl] = false }
|
68
56
|
|
69
57
|
it "sends a request" do
|
70
58
|
subject
|
71
|
-
expect(a_request(:post,
|
59
|
+
expect(a_request(:post, url)).to have_been_made
|
72
60
|
end
|
73
61
|
end
|
74
62
|
|
@@ -78,7 +66,7 @@ RSpec.describe SmsAero, "#check_balance" do
|
|
78
66
|
it "returns result" do
|
79
67
|
expect(subject).to be_kind_of SmsAero::Answer
|
80
68
|
|
81
|
-
expect(subject.result).to
|
69
|
+
expect(subject.result).to eq "rejected"
|
82
70
|
expect(subject).not_to respond_to :balance
|
83
71
|
end
|
84
72
|
end
|