zeppelin 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = 'zeppelin'
7
7
  s.version = Zeppelin::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ['Alexander Kern']
10
- s.email = ['alex@kernul.com']
9
+ s.authors = ['Alexander Kern', 'James Herdman']
10
+ s.email = ['alex@kernul.com', 'james.herdman@me.com']
11
11
  s.homepage = 'https://github.com/CapnKernul/zeppelin'
12
12
  s.summary = %q{Urban Airship library for Ruby}
13
13
  s.description = %q{Ruby client for the Urban Airship Push Notification API}
@@ -15,12 +15,9 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = 'zeppelin'
16
16
 
17
17
  s.add_dependency 'faraday'
18
- s.add_dependency 'yajl-ruby'
18
+ s.add_dependency 'multi_json', '~> 1.1'
19
19
 
20
- s.add_development_dependency 'minitest', '~> 2.0'
21
- s.add_development_dependency 'journo'
22
- s.add_development_dependency 'mocha'
23
- s.add_development_dependency 'test_declarative'
20
+ s.add_development_dependency 'rspec'
24
21
  s.add_development_dependency 'rake'
25
22
 
26
23
  s.files = `git ls-files`.split("\n")
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeppelin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alexander Kern
9
+ - James Herdman
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000Z
13
+ date: 2012-02-23 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: faraday
16
- requirement: &70115497098880 !ruby/object:Gem::Requirement
17
+ requirement: &70356824338980 !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ! '>='
@@ -21,54 +22,21 @@ dependencies:
21
22
  version: '0'
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *70115497098880
25
+ version_requirements: *70356824338980
25
26
  - !ruby/object:Gem::Dependency
26
- name: yajl-ruby
27
- requirement: &70115497097860 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70115497097860
36
- - !ruby/object:Gem::Dependency
37
- name: minitest
38
- requirement: &70115497095520 !ruby/object:Gem::Requirement
27
+ name: multi_json
28
+ requirement: &70356824337960 !ruby/object:Gem::Requirement
39
29
  none: false
40
30
  requirements:
41
31
  - - ~>
42
32
  - !ruby/object:Gem::Version
43
- version: '2.0'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70115497095520
47
- - !ruby/object:Gem::Dependency
48
- name: journo
49
- requirement: &70115497094220 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70115497094220
58
- - !ruby/object:Gem::Dependency
59
- name: mocha
60
- requirement: &70115497092480 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
33
+ version: '1.1'
34
+ type: :runtime
67
35
  prerelease: false
68
- version_requirements: *70115497092480
36
+ version_requirements: *70356824337960
69
37
  - !ruby/object:Gem::Dependency
70
- name: test_declarative
71
- requirement: &70115497090680 !ruby/object:Gem::Requirement
38
+ name: rspec
39
+ requirement: &70356824337460 !ruby/object:Gem::Requirement
72
40
  none: false
73
41
  requirements:
74
42
  - - ! '>='
@@ -76,10 +44,10 @@ dependencies:
76
44
  version: '0'
77
45
  type: :development
78
46
  prerelease: false
79
- version_requirements: *70115497090680
47
+ version_requirements: *70356824337460
80
48
  - !ruby/object:Gem::Dependency
81
49
  name: rake
82
- requirement: &70115497089600 !ruby/object:Gem::Requirement
50
+ requirement: &70356824336900 !ruby/object:Gem::Requirement
83
51
  none: false
84
52
  requirements:
85
53
  - - ! '>='
@@ -87,28 +55,33 @@ dependencies:
87
55
  version: '0'
88
56
  type: :development
89
57
  prerelease: false
90
- version_requirements: *70115497089600
58
+ version_requirements: *70356824336900
91
59
  description: Ruby client for the Urban Airship Push Notification API
92
60
  email:
93
61
  - alex@kernul.com
62
+ - james.herdman@me.com
94
63
  executables: []
95
64
  extensions: []
96
65
  extra_rdoc_files: []
97
66
  files:
98
- - .autotest
99
67
  - .gitignore
100
68
  - .travis.yml
101
69
  - .yardopts
70
+ - Changelog.md
102
71
  - Gemfile
72
+ - Guardfile
103
73
  - LICENSE
104
74
  - README.md
105
75
  - Rakefile
106
76
  - lib/zeppelin.rb
107
- - lib/zeppelin/json_parser_middleware.rb
77
+ - lib/zeppelin/middleware.rb
78
+ - lib/zeppelin/middleware/json_parser.rb
79
+ - lib/zeppelin/middleware/response_raise_error.rb
108
80
  - lib/zeppelin/version.rb
109
- - test/json_parser_middleware_test.rb
110
- - test/test_helper.rb
111
- - test/zeppelin_test.rb
81
+ - spec/middleware/json_parser_spec.rb
82
+ - spec/middleware/response_raise_error_spec.rb
83
+ - spec/spec_helper.rb
84
+ - spec/zeppelin_spec.rb
112
85
  - zeppelin.gemspec
113
86
  homepage: https://github.com/CapnKernul/zeppelin
114
87
  licenses: []
@@ -122,25 +95,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
95
  - - ! '>='
123
96
  - !ruby/object:Gem::Version
124
97
  version: '0'
125
- segments:
126
- - 0
127
- hash: 437314845617063875
128
98
  required_rubygems_version: !ruby/object:Gem::Requirement
129
99
  none: false
130
100
  requirements:
131
101
  - - ! '>='
132
102
  - !ruby/object:Gem::Version
133
103
  version: '0'
134
- segments:
135
- - 0
136
- hash: 437314845617063875
137
104
  requirements: []
138
105
  rubyforge_project: zeppelin
139
- rubygems_version: 1.8.10
106
+ rubygems_version: 1.8.17
140
107
  signing_key:
141
108
  specification_version: 3
142
109
  summary: Urban Airship library for Ruby
143
110
  test_files:
144
- - test/json_parser_middleware_test.rb
145
- - test/test_helper.rb
146
- - test/zeppelin_test.rb
111
+ - spec/middleware/json_parser_spec.rb
112
+ - spec/middleware/response_raise_error_spec.rb
113
+ - spec/spec_helper.rb
114
+ - spec/zeppelin_spec.rb
data/.autotest DELETED
@@ -1,15 +0,0 @@
1
- Autotest.add_hook :initialize do |at|
2
- # Requires bundler before minitest since the minitest bundled with Ruby does
3
- # not support runners.
4
- at.testlib = 'bundler/setup minitest/unit'
5
-
6
- # Mappings from http://opensoul.org/blog/archives/2008/08/22/autotest-mapping-for-rails-test-conventions/.
7
- at.clear_mappings
8
-
9
- at.add_mapping %r%/^lib/(.*)\.rb$% do |_, m|
10
- possible = File.basename(m[1])
11
- files_matching %r%^test/.*(#{possible}_test|test_#{possible})\.rb$%
12
- end
13
-
14
- at.add_mapping(%r%^test/.*\.rb$%) { |filename, _| filename }
15
- end
@@ -1,35 +0,0 @@
1
- require 'yajl'
2
-
3
- class Zeppelin
4
- # Middleware for Faraday that parses JSON response bodies. Based on code in
5
- # the FaradayMiddleware project.
6
- #
7
- # @private
8
- class JsonParserMiddleware < Faraday::Middleware
9
- CONTENT_TYPE = 'Content-Type'
10
-
11
- def initialize(app=nil)
12
- @app = app
13
- end
14
-
15
- def call(env)
16
- @app.call(env).on_complete do
17
- parse_response(env) if process_content_type?(env) && parse_response?(env)
18
- end
19
- end
20
-
21
- private
22
-
23
- def parse_response(env)
24
- env[:body] = Yajl::Parser.parse(env[:body])
25
- end
26
-
27
- def process_content_type?(env)
28
- env[:response_headers][CONTENT_TYPE].to_s =~ /\bjson$/
29
- end
30
-
31
- def parse_response?(env)
32
- env[:body].respond_to? :to_str
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- require 'test_helper'
2
-
3
- class JsonParserMiddlewareTest < Zeppelin::TestCase
4
- def setup
5
- @json_body = "{\"foo\":\"bar\"}"
6
- @expected_parsed_body = { 'foo' => 'bar' }
7
- end
8
-
9
- test 'parses a standard JSON content type' do
10
- assert_equal @expected_parsed_body, process(@json_body, 'application/json').body
11
- end
12
-
13
- test 'parses vendor JSON content type' do
14
- assert_equal @expected_parsed_body, process(@json_body, 'application/vnd.urbanairship+json').body
15
- end
16
-
17
- test 'does not change nil body' do
18
- assert process(nil).body.nil?
19
- end
20
-
21
- test 'does not parse non-JSON content types' do
22
- assert_equal '<hello>world</hello>', process('<hello>world</hello>', 'text/xml').body
23
- end
24
-
25
- def process(body, content_type=nil, options={})
26
- env = { :body => body, :response_headers => Faraday::Utils::Headers.new }
27
- env[:response_headers]['content-type'] = content_type if content_type
28
-
29
- middleware = Zeppelin::JsonParserMiddleware.new(
30
- lambda { |env| Faraday::Response.new(env) }
31
- )
32
-
33
- middleware.call(env)
34
- end
35
- end
@@ -1,13 +0,0 @@
1
- require 'bundler/setup'
2
- require 'minitest/autorun'
3
- require 'journo'
4
- require 'mocha'
5
- require 'test_declarative'
6
- require 'zeppelin'
7
-
8
- Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
9
-
10
- class Zeppelin::TestCase < MiniTest::Unit::TestCase; end
11
-
12
- MiniTest::Unit.runner = Journo::SuiteRunner.new
13
- MiniTest::Unit.runner.reporters << Journo::Reporters::ProgressReporter.new
@@ -1,453 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZeppelinTest < Zeppelin::TestCase
4
- def setup
5
- @client = Zeppelin.new('app key', 'app master secret')
6
- @device_token = '1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF'
7
- end
8
-
9
- test '#connection' do
10
- assert_instance_of Faraday::Connection, @client.connection
11
- assert_equal 'https', @client.connection.scheme
12
- assert_equal 'go.urbanairship.com', @client.connection.host
13
- assert_includes @client.connection.builder.handlers, Faraday::Adapter::NetHttp
14
- assert_includes @client.connection.builder.handlers, Faraday::Request::JSON
15
- assert_includes @client.connection.builder.handlers, Zeppelin::JsonParserMiddleware
16
- assert_equal 'Basic YXBwIGtleTphcHAgbWFzdGVyIHNlY3JldA==', @client.connection.headers['Authorization']
17
- end
18
-
19
- test '#initialize with custom options' do
20
- ssl_options = { :ca_path => '/dev/null' }
21
- @client = Zeppelin.new('app key', 'app master secret', :ssl => ssl_options)
22
- assert_equal(ssl_options, @client.connection.ssl)
23
- end
24
-
25
- test '#register_device_token without a payload' do
26
- stub_requests @client.connection do |stub|
27
- stub.put("/api/device_tokens/#{@device_token}") do [201, {}, '']
28
- end
29
- end
30
-
31
- response = @client.register_device_token(@device_token)
32
- assert response
33
- end
34
-
35
- test '#register_device_token an already registered device token' do
36
- stub_requests @client.connection do |stub|
37
- stub.put("/api/device_tokens/#{@device_token}") do
38
- [200, {}, '']
39
- end
40
- end
41
-
42
- response = @client.register_device_token(@device_token)
43
- assert response
44
- end
45
-
46
- test '#register_device_token with payload' do
47
- payload = { :alias => 'CapnKernul' }
48
-
49
- stub_requests @client.connection do |stub|
50
- stub.put("/api/device_tokens/#{@device_token}", Yajl::Encoder.encode(payload)) do
51
- [200, {}, '']
52
- end
53
- end
54
-
55
- response = @client.register_device_token(@device_token, payload)
56
- assert response
57
- end
58
-
59
- test '#register_device_token with an error' do
60
- stub_requests @client.connection do |stub|
61
- stub.put("/api/device_tokens/#{@device_token}", nil) do
62
- [500, {}, '']
63
- end
64
- end
65
-
66
- response = @client.register_device_token(@device_token)
67
- refute response
68
- end
69
-
70
- test '#device_token with valid device token' do
71
- response_body = { 'foo' => 'bar' }
72
- stub_requests @client.connection do |stub|
73
- stub.get("/api/device_tokens/#{@device_token}") do
74
- [200, { 'Content-Type' => 'application/json' }, Yajl::Encoder.encode(response_body)]
75
- end
76
- end
77
-
78
- response = @client.device_token(@device_token)
79
- assert_equal response_body, response
80
- end
81
-
82
- test '#device_token with an unknown device token' do
83
- stub_requests @client.connection do |stub|
84
- stub.get("/api/device_tokens/#{@device_token}") do
85
- [404, {}, '']
86
- end
87
- end
88
-
89
- response = @client.device_token(@device_token)
90
- assert_nil response
91
- end
92
-
93
- test '#delete_device_token with a valid device token' do
94
- stub_requests @client.connection do |stub|
95
- stub.delete("/api/device_tokens/#{@device_token}") do
96
- [204, {}, '']
97
- end
98
- end
99
-
100
- response = @client.delete_device_token(@device_token)
101
- assert response
102
- end
103
-
104
- test '#delete_device_token with an unknown device token' do
105
- stub_requests @client.connection do |stub|
106
- stub.delete("/api/device_tokens/#{@device_token}") do
107
- [404, {}, '']
108
- end
109
- end
110
-
111
- response = @client.delete_device_token(@device_token)
112
- refute response
113
- end
114
-
115
- test '#register_apid without a payload' do
116
- stub_requests @client.connection do |stub|
117
- stub.put("/api/apids/#{@apid}") do [201, {}, '']
118
- end
119
- end
120
-
121
- response = @client.register_apid(@apid)
122
- assert response
123
- end
124
-
125
- test '#register_apid an already registered APID' do
126
- stub_requests @client.connection do |stub|
127
- stub.put("/api/apids/#{@apid}") do
128
- [200, {}, '']
129
- end
130
- end
131
-
132
- response = @client.register_apid(@apid)
133
- assert response
134
- end
135
-
136
- test '#register_apid with payload' do
137
- payload = { :alias => 'CapnKernul' }
138
-
139
- stub_requests @client.connection do |stub|
140
- stub.put("/api/apids/#{@apid}", Yajl::Encoder.encode(payload)) do
141
- [200, {}, '']
142
- end
143
- end
144
-
145
- response = @client.register_apid(@apid, payload)
146
- assert response
147
- end
148
-
149
- test '#register_apid with an error' do
150
- stub_requests @client.connection do |stub|
151
- stub.put("/api/apids/#{@apid}", nil) do
152
- [500, {}, '']
153
- end
154
- end
155
-
156
- response = @client.register_apid(@apid)
157
- refute response
158
- end
159
-
160
- test '#apid' do
161
- response_body = { 'foo' => 'bar' }
162
- stub_requests @client.connection do |stub|
163
- stub.get("/api/apids/#{@apid}") do
164
- [200, { 'Content-Type' => 'application/json' }, Yajl::Encoder.encode(response_body)]
165
- end
166
- end
167
-
168
- response = @client.apid(@apid)
169
- assert_equal response_body, response
170
- end
171
-
172
- test '#delete_apid with a valid APID' do
173
- stub_requests @client.connection do |stub|
174
- stub.delete("/api/apids/#{@apid}") do
175
- [204, {}, '']
176
- end
177
- end
178
-
179
- response = @client.delete_apid(@apid)
180
- assert response
181
- end
182
-
183
- test '#delete_apid with an unknown APID' do
184
- stub_requests @client.connection do |stub|
185
- stub.delete("/api/apids/#{@apid}") do
186
- [404, {}, '']
187
- end
188
- end
189
-
190
- response = @client.delete_apid(@apid)
191
- refute response
192
- end
193
-
194
- test '#push with a valid payload' do
195
- payload = {
196
- :device_tokens => [@device_token],
197
- :aps => { :alert => 'Hello from Urban Airship!' }
198
- }
199
-
200
- stub_requests @client.connection do |stub|
201
- stub.post('/api/push/', Yajl::Encoder.encode(payload)) do
202
- [200, {}, '']
203
- end
204
- end
205
-
206
- response = @client.push(payload)
207
- assert response
208
- end
209
-
210
- # Although the Urban Airship documentation states that a 400 Status Code
211
- # will be sent when there's an invalid payload, it doesn't state what
212
- # constitutes an invalid payload. Hence, I'm just mocking out the request so
213
- # that it returns a 400.
214
- test '#push with an invalid payload' do
215
- stub_requests @client.connection do |stub|
216
- stub.post('/api/push/', '{}') do
217
- [400, {}, '']
218
- end
219
- end
220
-
221
- response = @client.push({})
222
- refute response
223
- end
224
-
225
- test '#batch_push with a valid payload' do
226
- message1 = {
227
- :device_tokens => [@device_token],
228
- :aps => { :alert => 'Hello from Urban Airship!' }
229
- }
230
-
231
- message2 = {
232
- :device_tokens => [],
233
- :aps => { :alert => 'Yet another hello from Urban Airship!' }
234
- }
235
-
236
- payload = [message1, message2]
237
-
238
- stub_requests @client.connection do |stub|
239
- stub.post('/api/push/batch/', Yajl::Encoder.encode(payload)) do
240
- [200, {}, '']
241
- end
242
- end
243
-
244
- response = @client.batch_push(message1, message2)
245
- assert response
246
- end
247
-
248
- # See the note above for why this test exists.
249
- test '#batch_push with an invalid payload' do
250
- stub_requests @client.connection do |stub|
251
- stub.post('/api/push/batch/', '[{},{}]') do
252
- [400, {}, '']
253
- end
254
- end
255
-
256
- response = @client.batch_push({}, {})
257
- refute response
258
- end
259
-
260
- test '#broadcast with a valid payload' do
261
- payload = {
262
- :aps => { :alert => 'Hello from Urban Airship!' }
263
- }
264
-
265
- stub_requests @client.connection do |stub|
266
- stub.post('/api/push/broadcast/', Yajl::Encoder.encode(payload)) do
267
- [200, {}, '']
268
- end
269
- end
270
-
271
- response = @client.broadcast(payload)
272
- assert response
273
- end
274
-
275
- # See the note above for why this test exists.
276
- test '#broadcast with an invalid payload' do
277
- stub_requests @client.connection do |stub|
278
- stub.post('/api/push/broadcast/', '{}') do
279
- [400, {}, '']
280
- end
281
- end
282
-
283
- response = @client.broadcast({})
284
- refute response
285
- end
286
-
287
- test '#feedback with a valid since' do
288
- response_body = { 'foo' => 'bar' }
289
- since = Time.at(0)
290
-
291
- stub_requests @client.connection do |stub|
292
- stub.get('/api/device_tokens/feedback/?since=1970-01-01T00%3A00%3A00Z') do
293
- [200, { 'Content-Type' => 'application/json' }, Yajl::Encoder.encode(response_body)]
294
- end
295
- end
296
-
297
- response = @client.feedback(since)
298
- assert_equal response_body, response
299
- end
300
-
301
- test '#feedback with an error' do
302
- since = Time.at(0)
303
-
304
- stub_requests @client.connection do |stub|
305
- stub.get('/api/device_tokens/feedback/?since=1970-01-01T00%3A00%3A00Z') do
306
- [400, {}, '']
307
- end
308
- end
309
-
310
- response = @client.feedback(since)
311
- assert_nil response
312
- end
313
-
314
- test '#tags' do
315
- response_body = { 'tags' => ['green', 'eggs'] }
316
-
317
- stub_requests @client.connection do |stub|
318
- stub.get('/api/tags/') do
319
- [200, { 'Content-Type' => 'application/json' }, Yajl::Encoder.encode(response_body)]
320
- end
321
- end
322
-
323
- response = @client.tags
324
- assert_equal response_body, response
325
- end
326
-
327
- test '#modify_device_token_on_tag' do
328
- tag_name = 'jimmy.page'
329
- device_token = 'CAFEBABE'
330
-
331
- stub_requests @client.connection do |stub|
332
- stub.post("/api/tags/#{tag_name}") do
333
- [200, {}, 'OK']
334
- end
335
- end
336
-
337
- response = @client.modify_device_tokens_on_tag(tag_name, { 'device_tokens' => { 'add' => [device_token] } })
338
- assert response
339
- end
340
-
341
- test '#add_tag' do
342
- tag_name = 'chunky.bacon'
343
-
344
- stub_requests @client.connection do |stub|
345
- stub.put("/api/tags/#{tag_name}") do
346
- [201, {}, '']
347
- end
348
- end
349
-
350
- response = @client.add_tag(tag_name)
351
- assert response
352
- end
353
-
354
- test '#remove_tag with an existing tag' do
355
- tag_name = 'cats.pajamas'
356
-
357
- stub_requests @client.connection do |stub|
358
- stub.delete("/api/tags/#{tag_name}") do
359
- [204, {}, '']
360
- end
361
- end
362
-
363
- response = @client.remove_tag(tag_name)
364
- assert response
365
- end
366
-
367
- test '#remove_tag with non-existant tag' do
368
- tag_name = 'cats.pajamas'
369
-
370
- stub_requests @client.connection do |stub|
371
- stub.delete("/api/tags/#{tag_name}") do
372
- [404, {}, 'Not Found']
373
- end
374
- end
375
-
376
- response = @client.remove_tag(tag_name)
377
- refute response
378
- end
379
-
380
- test '#device_tags with existing device' do
381
- device_token = 'CAFEBABE'
382
- response_body = { 'tags' => ['tag1', 'some_tag'] }
383
-
384
- stub_requests @client.connection do |stub|
385
- stub.get("/api/device_tokens/#{device_token}/tags/") do
386
- [200, { 'Content-Type' => 'application/json' }, Yajl::Encoder.encode(response_body)]
387
- end
388
- end
389
-
390
- response = @client.device_tags(device_token)
391
- assert_equal response_body, response
392
- end
393
-
394
- test '#device_tags with non-existant device' do
395
- device_token = 'CAFEBABE'
396
-
397
- stub_requests @client.connection do |stub|
398
- stub.get("/api/device_tokens/#{device_token}/tags/") do
399
- [404, {}, 'Not Found']
400
- end
401
- end
402
-
403
- response = @client.device_tags(device_token)
404
- refute response
405
- end
406
-
407
- test '#add_tag_to_device' do
408
- tag_name = 'radio.head'
409
- device_token = 'CAFEBABE'
410
-
411
- stub_requests @client.connection do |stub|
412
- stub.put("/api/device_tokens/#{device_token}/tags/#{tag_name}") do
413
- [201, {}, 'Created']
414
- end
415
- end
416
-
417
- response = @client.add_tag_to_device(device_token, tag_name)
418
- assert response
419
- end
420
-
421
- test '#remove_tag_from_device successfully' do
422
- tag_name = 'martin.fowler'
423
- device_token = 'DEADBEEF'
424
-
425
- stub_requests @client.connection do |stub|
426
- stub.delete("/api/device_tokens/#{device_token}/tags/#{tag_name}") do
427
- [204, {}, 'No Content']
428
- end
429
- end
430
-
431
- response = @client.remove_tag_from_device(device_token, tag_name)
432
- assert response
433
- end
434
-
435
- test '#remove_tag_from_device unsuccessfully' do
436
- tag_name = 'martin.fowler'
437
- device_token = 'DEADBEEF'
438
-
439
- stub_requests @client.connection do |stub|
440
- stub.delete("/api/device_tokens/#{device_token}/tags/#{tag_name}") do
441
- [404, {}, 'Not Found']
442
- end
443
- end
444
-
445
- response = @client.remove_tag_from_device(device_token, tag_name)
446
- refute response
447
- end
448
-
449
- def stub_requests(connection, &block)
450
- connection.builder.handlers.delete(Faraday::Adapter::NetHttp)
451
- connection.adapter(:test, &block)
452
- end
453
- end