mblox 0.1.0 → 0.2.0
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.
- checksums.yaml +8 -8
- data/lib/mblox/sms_response.rb +6 -6
- data/lib/mblox/version.rb +1 -1
- data/spec/sms_response_result_spec.rb +3 -3
- data/spec/sms_spec.rb +8 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MThhODgzMTYwYWZmMTdjNDJmNDAyZjY0MjUxMmE0Mzk3YzdmYjRiYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjgyYzE4MGMzNmU4ZDExOGI4NTgzNWE4YWEyODVjOTJlMmY4OTc2Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTFmODUwMmRhYmUyNGI1ODY4ZDQ4MTU4YzM1OTgyNmZlYmYxZGY3NWIyMzc0
|
10
|
+
Mjc1Y2I3YzNmZGI2Y2I5NzBjNDdjYWViNTM2OTVkOGZhMzBhYzRiNjVjZWYx
|
11
|
+
NjgxNzJlNTc0Mzc0YmU1ODM0NDJjMjhlZGY3Nzk3NGYzOGJmZjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGFkYTc4MGIyZmQyYWI3YjRlM2M5YjQ1MjE4OWJiOGMzNzM5ZjBkODlhMGRm
|
14
|
+
YWU5ODQ2ZjU0MGYxNWQ2ODBjODIzNDhiYTY3NTA3MDM0ZWUzNDE2NGI4OTRl
|
15
|
+
OTg3NmZkYjAxMzUxNmJkMjI5Yzc3ZDdjMjIyMzJjZGNlODMzYjA=
|
data/lib/mblox/sms_response.rb
CHANGED
@@ -21,7 +21,7 @@ module Mblox
|
|
21
21
|
@code, @text = (code.to_i.to_s == code ? code.to_i : code), text
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def ok?
|
25
25
|
0 == @code
|
26
26
|
end
|
27
27
|
|
@@ -50,7 +50,7 @@ module Mblox
|
|
50
50
|
@result = Result.new(result_list['NotificationResultCode'], result_list['NotificationResultText'])
|
51
51
|
@result = nil unless @result.valid?
|
52
52
|
|
53
|
-
if @result.
|
53
|
+
if @result.ok?
|
54
54
|
result_list = result_list['SubscriberResult']
|
55
55
|
raise MissingExpectedXmlContentError, "Xml should have contained a 'NotificationRequestResult' -> 'NotificationResultList' => 'NotificationResult' -> 'SubscriberResult' node, but was #{xml}" if result_list.blank?
|
56
56
|
@subscriber_result = Result.new(result_list['SubscriberResultCode'], result_list['SubscriberResultText'])
|
@@ -58,12 +58,12 @@ module Mblox
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
@request.
|
61
|
+
def ok?
|
62
|
+
@request.ok? && @result.ok? && @subscriber_result.ok?
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
66
|
-
@request.
|
65
|
+
def unroutable?
|
66
|
+
@request.ok? && @result.ok? && Result::UNROUTABLE == @subscriber_result
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
data/lib/mblox/version.rb
CHANGED
@@ -29,14 +29,14 @@ describe Mblox::SmsResponse::Result do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe "
|
32
|
+
describe "ok?" do
|
33
33
|
it "is true for code 0" do
|
34
|
-
described_class.new(0, "123").
|
34
|
+
described_class.new(0, "123").ok?.should be_true
|
35
35
|
end
|
36
36
|
|
37
37
|
10.times do |i|
|
38
38
|
it "is false for code #{i+1}" do
|
39
|
-
described_class.new(i+1, "123").
|
39
|
+
described_class.new(i+1, "123").ok?.should be_false
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/spec/sms_spec.rb
CHANGED
@@ -57,7 +57,7 @@ describe Mblox::Sms do
|
|
57
57
|
@mblox.message.should eq(["(MSG 1/4): #{message[0,145]}", "(MSG 2/4): #{message[145,145]}", "(MSG 3/4): #{message[290,145]}", "(MSG 4/4): #{message[435,145]}"])
|
58
58
|
response = @mblox.send
|
59
59
|
response.count.should eq(4)
|
60
|
-
response.each { |r| r.
|
60
|
+
response.each { |r| r.unroutable?.should be_true }
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should be split into multiple messages when longer than 160 characters if configured to split and not even split" do
|
@@ -67,7 +67,7 @@ describe Mblox::Sms do
|
|
67
67
|
@mblox.message.should eq(["(MSG 1/3): #{message[0,145]}", "(MSG 2/3): #{message[145,145]}", "(MSG 3/3): #{message[290..-1]}"])
|
68
68
|
response = @mblox.send
|
69
69
|
response.count.should eq(3)
|
70
|
-
response.each { |r| r.
|
70
|
+
response.each { |r| r.unroutable?.should be_true }
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should be safe from changing when short" do
|
@@ -96,8 +96,8 @@ describe Mblox::Sms do
|
|
96
96
|
|
97
97
|
describe "SMS messages" do
|
98
98
|
def expect_ok_response(response)
|
99
|
-
response.
|
100
|
-
response.
|
99
|
+
response.ok?.should be_true
|
100
|
+
response.unroutable?.should be_false
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should be sent when the phone number is a Fixnum" do
|
@@ -121,16 +121,16 @@ describe Mblox::Sms do
|
|
121
121
|
it "should be unroutable when sent to a landline" do
|
122
122
|
response = Mblox::Sms.new(LANDLINE,the_message).send
|
123
123
|
response.size.should eq(1)
|
124
|
-
response.first.
|
125
|
-
response.first.
|
124
|
+
response.first.unroutable?.should be_true, "#{response.first.inspect} should have been unroutable"
|
125
|
+
response.first.ok?.should be_false
|
126
126
|
end
|
127
127
|
|
128
128
|
"\r\n!\"#$\%&'\(\)*+,-.\/:;<=>?@_£¤¥§¿iÄÅÆÇÉÑÖØÜßáäåæèéìñòöøùü\tí¡ ".each_char do |i|
|
129
129
|
it "allows the special char #{i}, correctly escaping illegal XML characters where necessary" do
|
130
130
|
response = Mblox::Sms.new(LANDLINE,"#{the_message}#{i}#{the_message}").send
|
131
131
|
response.size.should eq(1)
|
132
|
-
response.first.
|
133
|
-
response.first.
|
132
|
+
response.first.ok?.should be_false
|
133
|
+
response.first.unroutable?.should be_true
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|