sms_aero 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +12 -0
- data/.travis.yml +17 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +126 -0
- data/Rakefile +6 -0
- data/lib/sms_aero.rb +55 -0
- data/lib/sms_aero/models/answer.rb +8 -0
- data/lib/sms_aero/models/sms.rb +15 -0
- data/lib/sms_aero/models/tariff.rb +8 -0
- data/lib/sms_aero/operations/add_blacklist.rb +11 -0
- data/lib/sms_aero/operations/add_group.rb +11 -0
- data/lib/sms_aero/operations/add_phone.rb +17 -0
- data/lib/sms_aero/operations/check_balance.rb +11 -0
- data/lib/sms_aero/operations/check_groups.rb +12 -0
- data/lib/sms_aero/operations/check_senders.rb +15 -0
- data/lib/sms_aero/operations/check_sending.rb +11 -0
- data/lib/sms_aero/operations/check_sign.rb +15 -0
- data/lib/sms_aero/operations/check_status.rb +11 -0
- data/lib/sms_aero/operations/check_tariff.rb +12 -0
- data/lib/sms_aero/operations/delete_group.rb +11 -0
- data/lib/sms_aero/operations/delete_phone.rb +12 -0
- data/lib/sms_aero/operations/send_sms.rb +17 -0
- data/lib/sms_aero/operations/send_to_group.rb +15 -0
- data/lib/sms_aero/types/birthday.rb +20 -0
- data/lib/sms_aero/types/channel.rb +4 -0
- data/lib/sms_aero/types/digital.rb +8 -0
- data/lib/sms_aero/types/filled_string.rb +3 -0
- data/lib/sms_aero/types/future.rb +16 -0
- data/lib/sms_aero/types/phone.rb +12 -0
- data/lib/sms_aero/types/sign_status.rb +9 -0
- data/sms_aero.gemspec +23 -0
- data/spec/sms_aero/operations/add_blacklist_spec.rb +88 -0
- data/spec/sms_aero/operations/add_group_spec.rb +88 -0
- data/spec/sms_aero/operations/add_phone_spec.rb +221 -0
- data/spec/sms_aero/operations/check_balance_spec.rb +85 -0
- data/spec/sms_aero/operations/check_groups_spec.rb +72 -0
- data/spec/sms_aero/operations/check_senders_spec.rb +98 -0
- data/spec/sms_aero/operations/check_sending_spec.rb +88 -0
- data/spec/sms_aero/operations/check_sign_spec.rb +87 -0
- data/spec/sms_aero/operations/check_status_spec.rb +88 -0
- data/spec/sms_aero/operations/check_tariff_spec.rb +72 -0
- data/spec/sms_aero/operations/delete_group_spec.rb +88 -0
- data/spec/sms_aero/operations/delete_phone_spec.rb +118 -0
- data/spec/sms_aero/operations/send_sms_spec.rb +179 -0
- data/spec/sms_aero/operations/send_to_group_spec.rb +171 -0
- data/spec/sms_aero/types/birthday_spec.rb +33 -0
- data/spec/sms_aero/types/channel_spec.rb +19 -0
- data/spec/sms_aero/types/digital_spec.rb +15 -0
- data/spec/sms_aero/types/future_spec.rb +38 -0
- data/spec/sms_aero/types/phone_spec.rb +21 -0
- data/spec/sms_aero/types/sign_status_spec.rb +19 -0
- data/spec/spec_helper.rb +20 -0
- metadata +205 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
RSpec.describe SmsAero, "#check_balance" do
|
2
|
+
let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
|
3
|
+
let(:client) { described_class.new(settings) }
|
4
|
+
let(:answer) { { result: "accepted", balance: "99.5", foo: "bar" } }
|
5
|
+
let(:params) { { foo: "bar" } }
|
6
|
+
|
7
|
+
before { stub_request(:any, //).to_return(body: answer.to_json) }
|
8
|
+
subject { client.check_balance(params) }
|
9
|
+
|
10
|
+
context "using ssl via POST:" do
|
11
|
+
let(:host) { "https://gate.smsaero.ru/balance" }
|
12
|
+
let(:query) { "answer=json&password=PASSWORD&user=LOGIN" }
|
13
|
+
|
14
|
+
it "sends a request" do
|
15
|
+
subject
|
16
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns success" do
|
20
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
21
|
+
|
22
|
+
expect(subject.result).to eq "accepted"
|
23
|
+
expect(subject.balance).to eq 99.5
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "via GET:" do
|
28
|
+
let(:host) { "https://gate.smsaero.ru/balance" }
|
29
|
+
let(:query) { "answer=json&password=PASSWORD&user=LOGIN" }
|
30
|
+
|
31
|
+
before { settings[:use_post] = false }
|
32
|
+
|
33
|
+
it "sends a request" do
|
34
|
+
subject
|
35
|
+
expect(a_request(:get, "#{host}?#{query}")).to have_been_made
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "not using ssl:" do
|
40
|
+
let(:host) { "http://gate.smsaero.ru/balance" }
|
41
|
+
let(:query) { "answer=json&password=PASSWORD&user=LOGIN" }
|
42
|
+
|
43
|
+
before { settings[:use_ssl] = false }
|
44
|
+
|
45
|
+
it "sends a request" do
|
46
|
+
subject
|
47
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
48
|
+
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
|
+
|
55
|
+
before { params[:user] = "USER" }
|
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" }
|
68
|
+
|
69
|
+
it "sends a request" do
|
70
|
+
subject
|
71
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "using ssl via POST:" do
|
76
|
+
let(:answer) { { result: "rejected" } }
|
77
|
+
|
78
|
+
it "returns result" do
|
79
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
80
|
+
|
81
|
+
expect(subject.result).to eq "rejected"
|
82
|
+
expect(subject).not_to respond_to :balance
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
RSpec.describe SmsAero, "#check_groups" do
|
2
|
+
let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
|
3
|
+
let(:client) { described_class.new(settings) }
|
4
|
+
let(:params) { { foo: "bar" } }
|
5
|
+
let(:answer) { { result: "accepted", reason: %w(customers employee) } }
|
6
|
+
|
7
|
+
before { stub_request(:any, //).to_return(body: answer.to_json) }
|
8
|
+
subject { client.check_groups(params) }
|
9
|
+
|
10
|
+
context "using ssl via POST:" do
|
11
|
+
let(:host) { "https://gate.smsaero.ru/checkgroup" }
|
12
|
+
let(:query) { "answer=json&password=PASSWORD&user=LOGIN" }
|
13
|
+
|
14
|
+
it "sends a request" do
|
15
|
+
subject
|
16
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns success" do
|
20
|
+
expect(subject.result).to eq "accepted"
|
21
|
+
expect(subject.channels).to eq %w(customers employee)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "via GET:" do
|
26
|
+
let(:host) { "https://gate.smsaero.ru/checkgroup" }
|
27
|
+
let(:query) { "answer=json&password=PASSWORD&user=LOGIN" }
|
28
|
+
|
29
|
+
before { settings[:use_post] = false }
|
30
|
+
|
31
|
+
it "sends a request" do
|
32
|
+
subject
|
33
|
+
expect(a_request(:get, "#{host}?#{query}")).to have_been_made
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "not using ssl:" do
|
38
|
+
let(:host) { "http://gate.smsaero.ru/checkgroup" }
|
39
|
+
let(:query) { "answer=json&password=PASSWORD&user=LOGIN" }
|
40
|
+
|
41
|
+
before { settings[:use_ssl] = false }
|
42
|
+
|
43
|
+
it "sends a request" do
|
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/checkgroup" }
|
51
|
+
let(:query) { "answer=json&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
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with custom password:" do
|
62
|
+
let(:host) { "https://gate.smsaero.ru/checkgroup" }
|
63
|
+
let(:query) { "answer=json&password=PSWD&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
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
RSpec.describe SmsAero, "#check_senders" do
|
2
|
+
let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
|
3
|
+
let(:client) { described_class.new(settings) }
|
4
|
+
let(:params) { { sign: "baz", foo: "bar" } }
|
5
|
+
let(:answer) { { data: %w(peter paul) } }
|
6
|
+
|
7
|
+
before { stub_request(:any, //).to_return(body: answer.to_json) }
|
8
|
+
subject { client.check_senders(params) }
|
9
|
+
|
10
|
+
context "using ssl via POST:" do
|
11
|
+
let(:host) { "https://gate.smsaero.ru/senders" }
|
12
|
+
let(:query) { "answer=json&password=PASSWORD&sign=baz&user=LOGIN" }
|
13
|
+
|
14
|
+
it "sends a request" do
|
15
|
+
subject
|
16
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns success" do
|
20
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
21
|
+
expect(subject.data).to eq %w(peter paul)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "via GET:" do
|
26
|
+
let(:host) { "https://gate.smsaero.ru/senders" }
|
27
|
+
let(:query) { "answer=json&password=PASSWORD&sign=baz&user=LOGIN" }
|
28
|
+
|
29
|
+
before { settings[:use_post] = false }
|
30
|
+
|
31
|
+
it "sends a request" do
|
32
|
+
subject
|
33
|
+
expect(a_request(:get, "#{host}?#{query}")).to have_been_made
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "not using ssl:" do
|
38
|
+
let(:host) { "http://gate.smsaero.ru/senders" }
|
39
|
+
let(:query) { "answer=json&password=PASSWORD&sign=baz&user=LOGIN" }
|
40
|
+
|
41
|
+
before { settings[:use_ssl] = false }
|
42
|
+
|
43
|
+
it "sends a request" do
|
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/senders" }
|
51
|
+
let(:query) { "answer=json&password=PASSWORD&sign=baz&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/senders" }
|
63
|
+
let(:query) { "answer=json&password=PSWD&sign=baz&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
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with invalid sign:" do
|
74
|
+
before { params[:sign] = "" }
|
75
|
+
|
76
|
+
it "raises an exception" do
|
77
|
+
expect { subject }.to raise_error(TypeError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "without a sign:" do
|
82
|
+
before { params.delete :sign }
|
83
|
+
|
84
|
+
it "raises an exception" do
|
85
|
+
expect { subject }.to raise_error(KeyError)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "when server reported an error:" do
|
90
|
+
let(:answer) { { result: "rejected", reason: "wrong request" } }
|
91
|
+
|
92
|
+
it "returns success" do
|
93
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
94
|
+
expect(subject.result).to eq "rejected"
|
95
|
+
expect(subject.reason).to eq "wrong request"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
RSpec.describe SmsAero, "#check_sending" do
|
2
|
+
let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
|
3
|
+
let(:client) { described_class.new(settings) }
|
4
|
+
let(:params) { { id: "foobar" } }
|
5
|
+
let(:answer) { { result: "accepted" } }
|
6
|
+
|
7
|
+
before { stub_request(:any, //).to_return(body: answer.to_json) }
|
8
|
+
subject { client.check_sending(params) }
|
9
|
+
|
10
|
+
context "using ssl via POST:" do
|
11
|
+
let(:host) { "https://gate.smsaero.ru/checksending" }
|
12
|
+
let(:query) { "answer=json&id=foobar&password=PASSWORD&user=LOGIN" }
|
13
|
+
|
14
|
+
it "sends a request" do
|
15
|
+
subject
|
16
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns success" do
|
20
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
21
|
+
expect(subject.result).to eq "accepted"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "via GET:" do
|
26
|
+
let(:host) { "https://gate.smsaero.ru/checksending" }
|
27
|
+
let(:query) { "answer=json&id=foobar&password=PASSWORD&user=LOGIN" }
|
28
|
+
|
29
|
+
before { settings[:use_post] = false }
|
30
|
+
|
31
|
+
it "sends a request" do
|
32
|
+
subject
|
33
|
+
expect(a_request(:get, "#{host}?#{query}")).to have_been_made
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "not using ssl:" do
|
38
|
+
let(:host) { "http://gate.smsaero.ru/checksending" }
|
39
|
+
let(:query) { "answer=json&id=foobar&password=PASSWORD&user=LOGIN" }
|
40
|
+
|
41
|
+
before { settings[:use_ssl] = false }
|
42
|
+
|
43
|
+
it "sends a request" do
|
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/checksending" }
|
51
|
+
let(:query) { "answer=json&id=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
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with custom password:" do
|
62
|
+
let(:host) { "https://gate.smsaero.ru/checksending" }
|
63
|
+
let(:query) { "answer=json&id=foobar&password=PSWD&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
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with invalid id:" do
|
74
|
+
before { params[:id] = "" }
|
75
|
+
|
76
|
+
it "raises an exception" do
|
77
|
+
expect { subject }.to raise_error(TypeError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "without a id:" do
|
82
|
+
before { params.delete :id }
|
83
|
+
|
84
|
+
it "raises an exception" do
|
85
|
+
expect { subject }.to raise_error(KeyError)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
RSpec.describe SmsAero, "#check_sign" do
|
2
|
+
let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
|
3
|
+
let(:client) { described_class.new(settings) }
|
4
|
+
let(:params) { { sign: "foo" } }
|
5
|
+
let(:answer) { %w(accepted pending) }
|
6
|
+
|
7
|
+
before { stub_request(:any, //).to_return(body: answer.to_json) }
|
8
|
+
subject { client.check_sign(params) }
|
9
|
+
|
10
|
+
context "using ssl via POST:" do
|
11
|
+
let(:host) { "https://gate.smsaero.ru/sign" }
|
12
|
+
let(:query) { "answer=json&password=PASSWORD&sign=foo&user=LOGIN" }
|
13
|
+
|
14
|
+
it "sends a request" do
|
15
|
+
subject
|
16
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns statuses" do
|
20
|
+
expect(subject.statuses).to eq %w(accepted pending)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "via GET:" do
|
25
|
+
let(:host) { "https://gate.smsaero.ru/sign" }
|
26
|
+
let(:query) { "answer=json&password=PASSWORD&sign=foo&user=LOGIN" }
|
27
|
+
|
28
|
+
before { settings[:use_post] = false }
|
29
|
+
|
30
|
+
it "sends a request" do
|
31
|
+
subject
|
32
|
+
expect(a_request(:get, "#{host}?#{query}")).to have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "not using ssl:" do
|
37
|
+
let(:host) { "http://gate.smsaero.ru/sign" }
|
38
|
+
let(:query) { "answer=json&password=PASSWORD&sign=foo&user=LOGIN" }
|
39
|
+
|
40
|
+
before { settings[:use_ssl] = false }
|
41
|
+
|
42
|
+
it "sends a request" do
|
43
|
+
subject
|
44
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with custom user:" do
|
49
|
+
let(:host) { "https://gate.smsaero.ru/sign" }
|
50
|
+
let(:query) { "answer=json&password=PASSWORD&sign=foo&user=USER" }
|
51
|
+
|
52
|
+
before { params[:user] = "USER" }
|
53
|
+
|
54
|
+
it "sends a request" do
|
55
|
+
subject
|
56
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "with custom password:" do
|
61
|
+
let(:host) { "https://gate.smsaero.ru/sign" }
|
62
|
+
let(:query) { "answer=json&password=PSWD&sign=foo&user=LOGIN" }
|
63
|
+
|
64
|
+
before { params[:password] = "PSWD" }
|
65
|
+
|
66
|
+
it "sends a request" do
|
67
|
+
subject
|
68
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "with invalid sign:" do
|
73
|
+
before { params[:sign] = "" }
|
74
|
+
|
75
|
+
it "raises an exception" do
|
76
|
+
expect { subject }.to raise_error(TypeError)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "without a sign:" do
|
81
|
+
before { params.delete :sign }
|
82
|
+
|
83
|
+
it "raises an exception" do
|
84
|
+
expect { subject }.to raise_error(KeyError)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
RSpec.describe SmsAero, "#check_status" do
|
2
|
+
let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
|
3
|
+
let(:client) { described_class.new(settings) }
|
4
|
+
let(:params) { { id: "foobar" } }
|
5
|
+
let(:answer) { { result: "accepted" } }
|
6
|
+
|
7
|
+
before { stub_request(:any, //).to_return(body: answer.to_json) }
|
8
|
+
subject { client.check_status(params) }
|
9
|
+
|
10
|
+
context "using ssl via POST:" do
|
11
|
+
let(:host) { "https://gate.smsaero.ru/status" }
|
12
|
+
let(:query) { "answer=json&id=foobar&password=PASSWORD&user=LOGIN" }
|
13
|
+
|
14
|
+
it "sends a request" do
|
15
|
+
subject
|
16
|
+
expect(a_request(:post, "#{host}?#{query}")).to have_been_made
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns success" do
|
20
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
21
|
+
expect(subject.result).to eq "accepted"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "via GET:" do
|
26
|
+
let(:host) { "https://gate.smsaero.ru/status" }
|
27
|
+
let(:query) { "answer=json&id=foobar&password=PASSWORD&user=LOGIN" }
|
28
|
+
|
29
|
+
before { settings[:use_post] = false }
|
30
|
+
|
31
|
+
it "sends a request" do
|
32
|
+
subject
|
33
|
+
expect(a_request(:get, "#{host}?#{query}")).to have_been_made
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "not using ssl:" do
|
38
|
+
let(:host) { "http://gate.smsaero.ru/status" }
|
39
|
+
let(:query) { "answer=json&id=foobar&password=PASSWORD&user=LOGIN" }
|
40
|
+
|
41
|
+
before { settings[:use_ssl] = false }
|
42
|
+
|
43
|
+
it "sends a request" do
|
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/status" }
|
51
|
+
let(:query) { "answer=json&id=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
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with custom password:" do
|
62
|
+
let(:host) { "https://gate.smsaero.ru/status" }
|
63
|
+
let(:query) { "answer=json&id=foobar&password=PSWD&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
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with invalid id:" do
|
74
|
+
before { params[:id] = "" }
|
75
|
+
|
76
|
+
it "raises an exception" do
|
77
|
+
expect { subject }.to raise_error(TypeError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "without a id:" do
|
82
|
+
before { params.delete :id }
|
83
|
+
|
84
|
+
it "raises an exception" do
|
85
|
+
expect { subject }.to raise_error(KeyError)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|