esendex 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/esendex/application_controller.rb +0 -0
- data/app/controllers/esendex/inbound_messages_controller.rb +0 -0
- data/app/controllers/esendex/message_delivered_events_controller.rb +0 -0
- data/app/controllers/esendex/message_failed_events_controller.rb +0 -0
- data/app/controllers/esendex/push_notification_handler.rb +0 -0
- data/config/routes.rb +0 -0
- data/lib/esendex.rb +0 -0
- data/lib/esendex/account.rb +0 -0
- data/lib/esendex/api_connection.rb +0 -0
- data/lib/esendex/dispatcher_result.rb +0 -0
- data/lib/esendex/engine.rb +0 -0
- data/lib/esendex/exceptions.rb +0 -0
- data/lib/esendex/hash_serialisation.rb +0 -0
- data/lib/esendex/inbound_message.rb +0 -0
- data/lib/esendex/message.rb +0 -0
- data/lib/esendex/message_batch_submission.rb +0 -0
- data/lib/esendex/message_delivered_event.rb +0 -0
- data/lib/esendex/message_failed_event.rb +0 -0
- data/lib/esendex/railtie.rb +0 -0
- data/lib/esendex/version.rb +1 -1
- data/lib/esendex/voice_message.rb +0 -0
- data/lib/tasks/esendex.rake +0 -0
- data/licence.txt +0 -0
- data/readme.md +5 -5
- data/spec/account_spec.rb +32 -32
- data/spec/api_connection_spec.rb +10 -10
- data/spec/controllers/message_delivered_events_controller_spec.rb +0 -0
- data/spec/controllers/push_notification_handler_spec.rb +9 -9
- data/spec/dummy/README.rdoc +0 -0
- data/spec/dummy/Rakefile +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -0
- data/spec/dummy/config.ru +0 -0
- data/spec/dummy/config/application.rb +0 -0
- data/spec/dummy/config/boot.rb +0 -0
- data/spec/dummy/config/environment.rb +0 -0
- data/spec/dummy/config/environments/development.rb +2 -3
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +1 -2
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/inflections.rb +0 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -0
- data/spec/dummy/config/initializers/secret_token.rb +0 -0
- data/spec/dummy/config/initializers/session_store.rb +0 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/spec/dummy/config/locales/en.yml +0 -0
- data/spec/dummy/config/routes.rb +0 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy/public/404.html +0 -0
- data/spec/dummy/public/422.html +0 -0
- data/spec/dummy/public/500.html +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -0
- data/spec/hash_serialisation_spec.rb +4 -4
- data/spec/inbound_message_spec.rb +6 -6
- data/spec/message_batch_submission_spec.rb +4 -4
- data/spec/message_delivered_event_spec.rb +4 -4
- data/spec/message_failed_event_spec.rb +4 -4
- data/spec/message_spec.rb +6 -6
- data/spec/spec_helper.rb +1 -0
- data/spec/voice_message_spec.rb +4 -4
- metadata +17 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6776e13698bd0f6945a8a47636a60ffc6f15e340
|
4
|
+
data.tar.gz: e1693289ee33e889708f5015a445b600f054e31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50bb0e389cd685bf85b53908a109e325a8a3203d47fd0bf251223107e21a00cfc51a4e9fb822f86875e3f864f7d2ca554f6e8cf06f6bcfafbd2a4134f069d7a9
|
7
|
+
data.tar.gz: 9b46c9d79326387584c555191794d9529060781c1a73579d1c5285c0d448226749d6cdc9330781be36badbc36f92a5703ff949d1dabf6989aa3b5afbab685a14
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/config/routes.rb
CHANGED
File without changes
|
data/lib/esendex.rb
CHANGED
File without changes
|
data/lib/esendex/account.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/esendex/engine.rb
CHANGED
File without changes
|
data/lib/esendex/exceptions.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/esendex/message.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/esendex/railtie.rb
CHANGED
File without changes
|
data/lib/esendex/version.rb
CHANGED
File without changes
|
data/lib/tasks/esendex.rake
CHANGED
File without changes
|
data/licence.txt
CHANGED
File without changes
|
data/readme.md
CHANGED
@@ -96,9 +96,9 @@ Classes are provided in the gem for deserialising the notifications: `MessageDel
|
|
96
96
|
message = InboundMessage.from_xml request.body
|
97
97
|
```
|
98
98
|
|
99
|
-
### Rails
|
99
|
+
### Rails 4
|
100
100
|
|
101
|
-
In order to simplify receipt of push notifications for Rails
|
101
|
+
In order to simplify receipt of push notifications for Rails users, the gem ships with mountable Rails controllers to handle the receipt of these notifications.
|
102
102
|
|
103
103
|
To mount the end points, add this to `routes.rb`
|
104
104
|
|
@@ -117,7 +117,7 @@ Esendex.message_delivered_event_handler = lambda { |notification|
|
|
117
117
|
}
|
118
118
|
```
|
119
119
|
|
120
|
-
Please be kind to us and don't perform anything potentially long running in this call back as our notifier may timeout the request and pass the
|
120
|
+
Please be kind to us and don't perform anything potentially long running in this call back as our notifier may timeout the request and pass the notification to the retry queue.
|
121
121
|
|
122
122
|
If you need to perform processing that may run for a longer time then using an async task system like [Resque](https://github.com/defunkt/resque) is recommended.
|
123
123
|
|
@@ -176,11 +176,11 @@ This project also ships with a `Guardfile` so you can run tests continuously.
|
|
176
176
|
|
177
177
|
## Contributing
|
178
178
|
|
179
|
-
We really welcome any thoughts or guidance on how this gem could best provide the hooks you need to consume our services in your applicaiton. Please fork and raise pull requests for any features you would like us to add or raise an [issue]((https://github.com/esendex/esendex
|
179
|
+
We really welcome any thoughts or guidance on how this gem could best provide the hooks you need to consume our services in your applicaiton. Please fork and raise pull requests for any features you would like us to add or raise an [issue]((https://github.com/esendex/esendex-ruby-sdk/issues)
|
180
180
|
|
181
181
|
Customers with more pressing issues should contact our support teams via the usual local phone number or by email: [support@esendex.com](mailto:support@esendex.com).
|
182
182
|
|
183
183
|
## Copyright
|
184
184
|
|
185
|
-
Copyright (c) 2011-
|
185
|
+
Copyright (c) 2011-18 Esendex Ltd. See licence.txt for further details.
|
186
186
|
|
data/spec/account_spec.rb
CHANGED
@@ -31,22 +31,22 @@ describe Account do
|
|
31
31
|
</account>
|
32
32
|
</accounts>"
|
33
33
|
}
|
34
|
-
let(:api_connection) {
|
34
|
+
let(:api_connection) { double("Connection", :get => double('Response', :body => account_xml), :post => true )}
|
35
35
|
|
36
36
|
before(:each) do
|
37
|
-
account.
|
37
|
+
allow(account).to receive(:api_connection) { api_connection }
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "#messages_remaining" do
|
41
41
|
subject { account.messages_remaining }
|
42
42
|
|
43
43
|
it "should get the account resource" do
|
44
|
-
api_connection.
|
44
|
+
expect(api_connection).to receive(:get).with("/v1.0/accounts")
|
45
45
|
subject
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should get the messages remaining from the document" do
|
49
|
-
subject.
|
49
|
+
expect(subject).to eq(messages_remaining)
|
50
50
|
end
|
51
51
|
|
52
52
|
context "with invalid reference" do
|
@@ -70,26 +70,26 @@ describe Account do
|
|
70
70
|
}
|
71
71
|
|
72
72
|
before(:each) do
|
73
|
-
api_connection.
|
73
|
+
allow(api_connection).to receive(:post) { double('Response', :body => send_response_xml) }
|
74
74
|
end
|
75
75
|
|
76
76
|
subject { account.send_message(to: "447815777555", body: "Hello from the Esendex Ruby Gem") }
|
77
77
|
|
78
78
|
it "should post to the message dispatcher resource" do
|
79
|
-
api_connection.
|
79
|
+
expect(api_connection).to receive(:post).with("/v1.0/messagedispatcher", anything)
|
80
80
|
subject
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should return the batch_id when treated as string" do
|
84
|
-
subject.to_s.
|
84
|
+
expect(subject.to_s).to eq(batch_id)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should return the batch_id in the result" do
|
88
|
-
subject.batch_id.
|
88
|
+
expect(subject.batch_id).to eq(batch_id)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should provide a list of messages with a single message" do
|
92
|
-
subject.messages.
|
92
|
+
expect(subject.messages).to have(1).items
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -107,45 +107,45 @@ describe Account do
|
|
107
107
|
}
|
108
108
|
|
109
109
|
before(:each) do
|
110
|
-
api_connection.
|
110
|
+
allow(api_connection).to receive(:post) { double('Response', :body => send_response_xml) }
|
111
111
|
end
|
112
112
|
|
113
113
|
subject { account.send_message(to: "447815777555", body: "Hello from the Esendex Ruby Gem") }
|
114
114
|
|
115
115
|
it "should post to the message dispatcher resource" do
|
116
|
-
api_connection.
|
116
|
+
expect(api_connection).to receive(:post).with("/v1.0/messagedispatcher", anything)
|
117
117
|
subject
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should provide a list containing two messages" do
|
121
|
-
subject.messages.
|
121
|
+
expect(subject.messages).to have(2).items
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should have message one in the message list" do
|
125
|
-
subject.messages.
|
125
|
+
expect(subject.messages).to include(id: "#{message_one_id}", uri: "#{uri_prefix}#{message_one_id}")
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should have message two in the message list" do
|
129
|
-
subject.messages.
|
129
|
+
expect(subject.messages).to include(id: "#{message_two_id}", uri: "#{uri_prefix}#{message_two_id}")
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
describe "#sent_messages" do
|
134
|
-
let(:sent_message_client) {
|
134
|
+
let(:sent_message_client) { double("sent_message_client") }
|
135
135
|
let(:sent_messages_result) { Class.new }
|
136
136
|
|
137
137
|
before(:each) do
|
138
138
|
stub_const("Esendex::SentMessageClient", sent_message_client)
|
139
|
-
sent_message_client
|
140
|
-
.
|
139
|
+
expect(sent_message_client)
|
140
|
+
.to receive(:new)
|
141
141
|
.with(api_connection)
|
142
142
|
.and_return(sent_message_client)
|
143
143
|
end
|
144
144
|
|
145
145
|
context "with no args" do
|
146
146
|
before(:each) do
|
147
|
-
sent_message_client
|
148
|
-
.
|
147
|
+
expect(sent_message_client)
|
148
|
+
.to receive(:get_messages)
|
149
149
|
.with({account_reference: account_reference})
|
150
150
|
.and_return(sent_messages_result)
|
151
151
|
end
|
@@ -153,7 +153,7 @@ describe Account do
|
|
153
153
|
subject { account.sent_messages() }
|
154
154
|
|
155
155
|
it "should return expected result" do
|
156
|
-
subject.
|
156
|
+
expect(subject).to eq(sent_messages_result)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
@@ -161,24 +161,24 @@ describe Account do
|
|
161
161
|
it "should pass dates without adjustment" do
|
162
162
|
start_date = DateTime.now - 30
|
163
163
|
finish_date = DateTime.now - 15
|
164
|
-
sent_message_client
|
165
|
-
.
|
164
|
+
expect(sent_message_client)
|
165
|
+
.to receive(:get_messages)
|
166
166
|
.with({account_reference: account_reference, start: start_date, finish: finish_date})
|
167
167
|
.and_return(sent_messages_result)
|
168
168
|
|
169
|
-
account.sent_messages({start: start_date, finish: finish_date}).
|
169
|
+
expect(account.sent_messages({start: start_date, finish: finish_date})).to_not be_nil
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
173
|
context "with start date" do
|
174
174
|
it "should specify start date and default finish date" do
|
175
175
|
start_date = DateTime.now - 1
|
176
|
-
sent_message_client
|
177
|
-
.
|
176
|
+
expect(sent_message_client)
|
177
|
+
.to receive(:get_messages)
|
178
178
|
.with({account_reference: account_reference, start: start_date})
|
179
179
|
.and_return(sent_messages_result)
|
180
180
|
|
181
|
-
account.sent_messages({start: start_date}).
|
181
|
+
expect(account.sent_messages({start: start_date})).to_not be_nil
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
@@ -186,12 +186,12 @@ describe Account do
|
|
186
186
|
it "should specify default start date and finish date" do
|
187
187
|
finish_date = DateTime.now - 1
|
188
188
|
start_date = finish_date - 90
|
189
|
-
sent_message_client
|
190
|
-
.
|
189
|
+
expect(sent_message_client)
|
190
|
+
.to receive(:get_messages)
|
191
191
|
.with({account_reference: account_reference, finish: finish_date})
|
192
192
|
.and_return(sent_messages_result)
|
193
193
|
|
194
|
-
account.sent_messages({finish: finish_date}).
|
194
|
+
expect(account.sent_messages({finish: finish_date})).to_not be_nil
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
@@ -199,12 +199,12 @@ describe Account do
|
|
199
199
|
it "should pass expected arguments" do
|
200
200
|
start_index = 3
|
201
201
|
count = 35
|
202
|
-
sent_message_client
|
203
|
-
.
|
202
|
+
expect(sent_message_client)
|
203
|
+
.to receive(:get_messages)
|
204
204
|
.with({account_reference: account_reference, start_index: start_index, count: count})
|
205
205
|
.and_return(sent_messages_result)
|
206
206
|
|
207
|
-
account.sent_messages({start_index: start_index, count: count}).
|
207
|
+
expect(account.sent_messages({start_index: start_index, count: count})).to_not be_nil
|
208
208
|
end
|
209
209
|
end
|
210
210
|
end
|
data/spec/api_connection_spec.rb
CHANGED
@@ -5,9 +5,9 @@ describe ApiConnection do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@connection = Nestful::Connection.new Esendex::API_HOST
|
8
|
-
Nestful::Connection.
|
9
|
-
@connection.
|
10
|
-
@connection.
|
8
|
+
allow(Nestful::Connection).to receive(:new) { @connection }
|
9
|
+
allow(@connection).to receive(:get) {}
|
10
|
+
allow(@connection).to receive(:post) {}
|
11
11
|
Esendex.configure do |config|
|
12
12
|
config.username = random_string
|
13
13
|
config.password = random_string
|
@@ -19,17 +19,17 @@ describe ApiConnection do
|
|
19
19
|
|
20
20
|
it "should set the username" do
|
21
21
|
subject
|
22
|
-
@connection.user.
|
22
|
+
expect(@connection.user).to eq(Esendex.username)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should set the password" do
|
26
26
|
subject
|
27
|
-
@connection.password.
|
27
|
+
expect(@connection.password).to eq(Esendex.password)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should set the auth to basic" do
|
31
31
|
subject
|
32
|
-
@connection.auth_type.
|
32
|
+
expect(@connection.auth_type).to eq(:basic)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -40,13 +40,13 @@ describe ApiConnection do
|
|
40
40
|
subject { api_connection.get url }
|
41
41
|
|
42
42
|
it "should call get with headers" do
|
43
|
-
@connection.
|
43
|
+
expect(@connection).to receive(:get).with(url, api_connection.default_headers)
|
44
44
|
subject
|
45
45
|
end
|
46
46
|
|
47
47
|
context "when 403 raised" do
|
48
48
|
before(:each) do
|
49
|
-
@connection.
|
49
|
+
allow(@connection).to receive(:get) { raise Nestful::ForbiddenAccess.new(nil) }
|
50
50
|
end
|
51
51
|
|
52
52
|
it "raises an ForbiddenError" do
|
@@ -62,13 +62,13 @@ describe ApiConnection do
|
|
62
62
|
subject { api_connection.post url, body }
|
63
63
|
|
64
64
|
it "should call post with headers" do
|
65
|
-
@connection.
|
65
|
+
expect(@connection).to receive(:post).with(url, body, api_connection.default_headers)
|
66
66
|
subject
|
67
67
|
end
|
68
68
|
|
69
69
|
context "when 403 raised" do
|
70
70
|
before(:each) do
|
71
|
-
@connection.
|
71
|
+
allow(@connection).to receive(:post) { raise Nestful::ForbiddenAccess.new(nil) }
|
72
72
|
end
|
73
73
|
|
74
74
|
it "raises an ForbiddenError" do
|
File without changes
|
@@ -11,9 +11,9 @@ module Esendex
|
|
11
11
|
subject { controller.process_notification @type, @source }
|
12
12
|
|
13
13
|
before(:each) do
|
14
|
-
@logger =
|
15
|
-
controller.
|
16
|
-
controller.
|
14
|
+
@logger = double('Logger', info: true)
|
15
|
+
allow(controller).to receive(:logger) { @logger }
|
16
|
+
allow(controller).to receive(:render)
|
17
17
|
end
|
18
18
|
|
19
19
|
@notifications = {
|
@@ -58,7 +58,7 @@ module Esendex
|
|
58
58
|
@source = config[:source]
|
59
59
|
@notification_class = config[:class]
|
60
60
|
@notification = @notification_class.from_xml(@source)
|
61
|
-
@notification_class.
|
61
|
+
allow(@notification_class).to receive(:from_xml) { @notification }
|
62
62
|
end
|
63
63
|
|
64
64
|
context "when a handler is configured" do
|
@@ -66,16 +66,16 @@ module Esendex
|
|
66
66
|
Esendex.send("#{notification_type}_handler=", @handler)
|
67
67
|
end
|
68
68
|
it "initializes a #{config[:class].name} from the source" do
|
69
|
-
@notification_class.
|
69
|
+
expect(@notification_class).to receive(:from_xml).with(@source)
|
70
70
|
subject
|
71
71
|
end
|
72
72
|
it "calls the handler" do
|
73
|
-
@handler.
|
73
|
+
expect(@handler).to receive(:call).with(@notification)
|
74
74
|
subject
|
75
75
|
end
|
76
76
|
it "the handler can process the input" do
|
77
77
|
subject
|
78
|
-
@received_id.
|
78
|
+
expect(@received_id).to eq(@notification.id)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
context "when no handler configured" do
|
@@ -83,11 +83,11 @@ module Esendex
|
|
83
83
|
Esendex.send("#{notification_type}_handler=", nil)
|
84
84
|
end
|
85
85
|
it "does not init a #{config[:class].name}" do
|
86
|
-
@notification_class.
|
86
|
+
expect(@notification_class).to_not receive(:from_xml)
|
87
87
|
subject
|
88
88
|
end
|
89
89
|
it "should log info line" do
|
90
|
-
@logger.
|
90
|
+
expect(@logger).to receive(:info).with(/#{notification_type.to_s}/)
|
91
91
|
subject
|
92
92
|
end
|
93
93
|
end
|
data/spec/dummy/README.rdoc
CHANGED
File without changes
|
data/spec/dummy/Rakefile
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/dummy/config.ru
CHANGED
File without changes
|
File without changes
|
data/spec/dummy/config/boot.rb
CHANGED
File without changes
|
File without changes
|
@@ -6,13 +6,12 @@ Dummy::Application.configure do
|
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
10
|
-
config.whiny_nils = true
|
11
|
-
|
12
9
|
# Show full error reports and disable caching
|
13
10
|
config.consider_all_requests_local = true
|
14
11
|
config.action_controller.perform_caching = false
|
15
12
|
|
13
|
+
config.eager_load = false
|
14
|
+
|
16
15
|
# Don't care if the mailer can't send
|
17
16
|
# config.action_mailer.raise_delivery_errors = false
|
18
17
|
|
@@ -8,6 +8,8 @@ Dummy::Application.configure do
|
|
8
8
|
config.consider_all_requests_local = false
|
9
9
|
config.action_controller.perform_caching = true
|
10
10
|
|
11
|
+
config.eager_load = true
|
12
|
+
|
11
13
|
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
14
|
# config.serve_static_assets = false
|
13
15
|
|
@@ -11,8 +11,7 @@ Dummy::Application.configure do
|
|
11
11
|
# config.serve_static_assets = true
|
12
12
|
# config.static_cache_control = "public, max-age=3600"
|
13
13
|
|
14
|
-
|
15
|
-
config.whiny_nils = true
|
14
|
+
config.eager_load = false
|
16
15
|
|
17
16
|
# Show full error reports and disable caching
|
18
17
|
config.consider_all_requests_local = true
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/dummy/config/routes.rb
CHANGED
File without changes
|
File without changes
|
data/spec/dummy/public/404.html
CHANGED
File without changes
|
data/spec/dummy/public/422.html
CHANGED
File without changes
|
data/spec/dummy/public/500.html
CHANGED
File without changes
|
File without changes
|
data/spec/dummy/script/rails
CHANGED
File without changes
|
@@ -22,13 +22,13 @@ module Esendex
|
|
22
22
|
subject { DummyHashSerialisation.new @attrs }
|
23
23
|
|
24
24
|
it "sets the name" do
|
25
|
-
subject.name.
|
25
|
+
expect(subject.name).to eq(name)
|
26
26
|
end
|
27
27
|
it "sets the time" do
|
28
|
-
subject.time.
|
28
|
+
expect(subject.time).to eq(time)
|
29
29
|
end
|
30
30
|
it "sets the notes" do
|
31
|
-
subject.notes.
|
31
|
+
expect(subject.notes).to eq(notes)
|
32
32
|
end
|
33
33
|
|
34
34
|
context "when invalid attribute passed" do
|
@@ -45,7 +45,7 @@ module Esendex
|
|
45
45
|
subject { DummyHashSerialisation.new(@attrs).to_hash }
|
46
46
|
|
47
47
|
it "should match the init hash" do
|
48
|
-
subject.
|
48
|
+
expect(subject).to eq(@attrs)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -22,22 +22,22 @@ describe InboundMessage do
|
|
22
22
|
subject { InboundMessage.from_xml source }
|
23
23
|
|
24
24
|
it "should set the id" do
|
25
|
-
subject.id.
|
25
|
+
expect(subject.id).to eq(id)
|
26
26
|
end
|
27
27
|
it "should set the message_id" do
|
28
|
-
subject.message_id.
|
28
|
+
expect(subject.message_id).to eq(message_id)
|
29
29
|
end
|
30
30
|
it "should set the account_id" do
|
31
|
-
subject.account_id.
|
31
|
+
expect(subject.account_id).to eq(account_id)
|
32
32
|
end
|
33
33
|
it "should set the message_text" do
|
34
|
-
subject.message_text.
|
34
|
+
expect(subject.message_text).to eq(message_text)
|
35
35
|
end
|
36
36
|
it "should set the from" do
|
37
|
-
subject.from.
|
37
|
+
expect(subject.from).to eq(from)
|
38
38
|
end
|
39
39
|
it "should set the to" do
|
40
|
-
subject.to.
|
40
|
+
expect(subject.to).to eq(to)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -10,18 +10,18 @@ describe MessageBatchSubmission do
|
|
10
10
|
subject { message_batch.xml_node }
|
11
11
|
|
12
12
|
it "creates message nodes" do
|
13
|
-
subject.xpath('//messages/message').count.
|
13
|
+
expect(subject.xpath('//messages/message').count).to eq(messages.count)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "sets the message to" do
|
17
17
|
(0..1).each do |i|
|
18
|
-
subject.xpath('//messages/message/to')[i].content.
|
18
|
+
expect(subject.xpath('//messages/message/to')[i].content).to eq(messages[i].to)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
it "sets the message body" do
|
23
23
|
(0..1).each do |i|
|
24
|
-
subject.xpath('//messages/message/body')[i].content.
|
24
|
+
expect(subject.xpath('//messages/message/body')[i].content).to eq(messages[i].body)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -33,7 +33,7 @@ describe MessageBatchSubmission do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "creates a properly formatted sendat node" do
|
36
|
-
subject.at_xpath('//messages/sendat').content.
|
36
|
+
expect(subject.at_xpath('//messages/sendat').content).to eq("2011-04-07T15:00:00")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -18,16 +18,16 @@ describe MessageDeliveredEvent do
|
|
18
18
|
subject { MessageDeliveredEvent.from_xml source }
|
19
19
|
|
20
20
|
it "should set the id" do
|
21
|
-
subject.id.
|
21
|
+
expect(subject.id).to eq(id)
|
22
22
|
end
|
23
23
|
it "should set the message_id" do
|
24
|
-
subject.message_id.
|
24
|
+
expect(subject.message_id).to eq(message_id)
|
25
25
|
end
|
26
26
|
it "should set the account_id" do
|
27
|
-
subject.account_id.
|
27
|
+
expect(subject.account_id).to eq(account_id)
|
28
28
|
end
|
29
29
|
it "should set the occurred_at" do
|
30
|
-
subject.occurred_at.to_i.
|
30
|
+
expect(subject.occurred_at.to_i).to eq(occurred_at.to_i)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -18,16 +18,16 @@ describe MessageFailedEvent do
|
|
18
18
|
subject { MessageFailedEvent.from_xml source }
|
19
19
|
|
20
20
|
it "should set the id" do
|
21
|
-
subject.id.
|
21
|
+
expect(subject.id).to eq(id)
|
22
22
|
end
|
23
23
|
it "should set the message_id" do
|
24
|
-
subject.message_id.
|
24
|
+
expect(subject.message_id).to eq(message_id)
|
25
25
|
end
|
26
26
|
it "should set the account_id" do
|
27
|
-
subject.account_id.
|
27
|
+
expect(subject.account_id).to eq(account_id)
|
28
28
|
end
|
29
29
|
it "should set the occurred_at" do
|
30
|
-
subject.occurred_at.to_i.
|
30
|
+
expect(subject.occurred_at.to_i).to eq(occurred_at.to_i)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/spec/message_spec.rb
CHANGED
@@ -8,15 +8,15 @@ describe Message do
|
|
8
8
|
let(:message) { Esendex::Message.new(to, body, from) }
|
9
9
|
|
10
10
|
it "should have to set" do
|
11
|
-
message.to.
|
11
|
+
expect(message.to).to eq(to)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should have from set" do
|
15
|
-
message.from.
|
15
|
+
expect(message.from).to eq(from)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should have body set" do
|
19
|
-
message.body.
|
19
|
+
expect(message.body).to eq(body)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -28,10 +28,10 @@ describe Message do
|
|
28
28
|
subject { message.xml_node }
|
29
29
|
|
30
30
|
it "contains a to node" do
|
31
|
-
subject.at_xpath('//message/to').content.
|
31
|
+
expect(subject.at_xpath('//message/to').content).to eq(to)
|
32
32
|
end
|
33
33
|
it "contains a body node" do
|
34
|
-
subject.at_xpath('//message/body').content.
|
34
|
+
expect(subject.at_xpath('//message/body').content).to eq(body)
|
35
35
|
end
|
36
36
|
|
37
37
|
context "when #from set" do
|
@@ -42,7 +42,7 @@ describe Message do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "contains a from node" do
|
45
|
-
subject.at_xpath('//message/from').content.
|
45
|
+
expect(subject.at_xpath('//message/from').content).to eq(from)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/voice_message_spec.rb
CHANGED
@@ -10,19 +10,19 @@ describe VoiceMessage do
|
|
10
10
|
|
11
11
|
context 'its xml' do
|
12
12
|
it "contains to" do
|
13
|
-
subject.at_xpath('//message/to').content.
|
13
|
+
expect(subject.at_xpath('//message/to').content).to eq(to)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "contains body" do
|
17
|
-
subject.at_xpath('//message/body').content.
|
17
|
+
expect(subject.at_xpath('//message/body').content).to eq(body)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "contains type" do
|
21
|
-
subject.at_xpath('//message/type').content.
|
21
|
+
expect(subject.at_xpath('//message/type').content).to eq('Voice')
|
22
22
|
end
|
23
23
|
|
24
24
|
it "contains language" do
|
25
|
-
subject.at_xpath('//message/lang').content.
|
25
|
+
expect(subject.at_xpath('//message/lang').content).to eq('en-GB')
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esendex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bird
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nestful
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
31
34
|
- - ">="
|
32
35
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
36
|
+
version: 1.8.2
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.8'
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
46
|
+
version: 1.8.2
|
41
47
|
description: Send SMS from your application using the Esendex API
|
42
48
|
email:
|
43
49
|
- support@esendex.com
|
@@ -97,6 +103,7 @@ files:
|
|
97
103
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
98
104
|
- spec/dummy/config/locales/en.yml
|
99
105
|
- spec/dummy/config/routes.rb
|
106
|
+
- spec/dummy/log/test.log
|
100
107
|
- spec/dummy/public/404.html
|
101
108
|
- spec/dummy/public/422.html
|
102
109
|
- spec/dummy/public/500.html
|
@@ -111,7 +118,8 @@ files:
|
|
111
118
|
- spec/spec_helper.rb
|
112
119
|
- spec/voice_message_spec.rb
|
113
120
|
homepage: http://developers.esendex.com
|
114
|
-
licenses:
|
121
|
+
licenses:
|
122
|
+
- Nonstandard
|
115
123
|
metadata: {}
|
116
124
|
post_install_message:
|
117
125
|
rdoc_options: []
|
@@ -119,9 +127,9 @@ require_paths:
|
|
119
127
|
- lib
|
120
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
129
|
requirements:
|
122
|
-
- - "
|
130
|
+
- - "~>"
|
123
131
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
132
|
+
version: '2.2'
|
125
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
134
|
requirements:
|
127
135
|
- - ">="
|
@@ -129,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
137
|
version: '0'
|
130
138
|
requirements: []
|
131
139
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.6.11
|
133
141
|
signing_key:
|
134
142
|
specification_version: 4
|
135
143
|
summary: Gem for interacting with the Esendex API
|
@@ -158,6 +166,7 @@ test_files:
|
|
158
166
|
- spec/dummy/config/locales/en.yml
|
159
167
|
- spec/dummy/config/routes.rb
|
160
168
|
- spec/dummy/config.ru
|
169
|
+
- spec/dummy/log/test.log
|
161
170
|
- spec/dummy/public/404.html
|
162
171
|
- spec/dummy/public/422.html
|
163
172
|
- spec/dummy/public/500.html
|