hipchat 1.5.3 → 1.5.4

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cbeb4474e9bae99465b61d971e6d5ac53f4562f1
4
- data.tar.gz: a9e7ec6445f91871676065bf26a0c19c817d511c
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDBiYjZkZDVmYzJiYTFlMGI0YWVjZTZkNGIxMzI2ZTkzOTc0Yzk5OA==
5
+ data.tar.gz: !binary |-
6
+ ZjE0YmMzM2MxNjEwZjUyZTg5MGU2MDUxYTlkMjQ0MjZmMGU0ZmM5YQ==
5
7
  SHA512:
6
- metadata.gz: e50b678c47c408557c8443352086ab4fd2020b5d7eaad21741eddae2dfc3866ce06cb333afe0df329814d8f946ae18e0d2d14319f5a4d85b1bc331fed22aed3a
7
- data.tar.gz: 87e12c6fcc6e94dd7b609eed2cb9f9f32626bedbe14fbe8f32f40c57c3e1abb746b88713973794e267e2beeda814da8441ed660f96ceef4e4fa32b728213078b
8
+ metadata.gz: !binary |-
9
+ NGJlOGFhMGQzOTBhYjliZDg5ZTI0OGRkNWVlYWU3ZDBmYmM2ZGI1ZDBiODYz
10
+ OGExMmFmNzE2ZGUwZGFhNWUxNDRkZGIxNGI3ODE4M2YxMjYxNDE4ZWEzYWMz
11
+ Zjk4NTcyZjE5YzI5M2QyM2JlNjM0MjU3OWZhM2I5YWJmNTA0ZTU=
12
+ data.tar.gz: !binary |-
13
+ MjIyMzRmNDMxZTA2NjE2NmI0NDllOTI5MGZkYTc5MTlmNTVhMzc4NzE5NGE1
14
+ NjkzNTMyMjAyNTJmMjE0YTFjNTU3OWZjYjY2MGE5NTk1MTA3ZGE4OWU1NDY2
15
+ N2JlZjhiNzY1MGUyODkxZjBkMDBlYzdlNDM3ZGYyNTA3OTQzYTU=
@@ -25,9 +25,10 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  spec.add_development_dependency "rr"
28
- spec.add_development_dependency "bundler", "~> 1.11.1"
28
+ spec.add_development_dependency "bundler", "~> 1.13.0"
29
29
  spec.add_development_dependency "rake"
30
30
  spec.add_development_dependency "webmock", "= 1.22.1"
31
31
  spec.add_development_dependency 'rdoc', '> 2.4.2'
32
+ spec.add_development_dependency 'tins', '~> 1.6.0'
32
33
  spec.add_development_dependency 'coveralls'
33
34
  end
@@ -1,5 +1,3 @@
1
- require 'hipchat'
2
-
3
1
  module HipChat
4
2
  class Railtie < Rails::Railtie
5
3
  rake_tasks do
@@ -19,7 +19,10 @@ module HipChat
19
19
  #
20
20
  # Send a private message to user.
21
21
  #
22
- def send(message, message_format='text', notify=false)
22
+ def send(message, options = {})
23
+ message_format = options[:message_format] ? options[:message_format] : 'text'
24
+ notify = options[:notify] ? options[:notify] : false
25
+
23
26
  response = self.class.post(@api.send_config[:url],
24
27
  :query => { :auth_token => @token },
25
28
  :body => {
@@ -1,3 +1,3 @@
1
1
  module HipChat
2
- VERSION = '1.5.3'
2
+ VERSION = '1.5.4'
3
3
  end
@@ -28,25 +28,18 @@ describe "HipChat (API V1)" do
28
28
  end
29
29
 
30
30
  it "fails when the room doen't exist" do
31
- mock(HipChat::Room).get(anything, anything) {
32
- OpenStruct.new(:code => 404)
33
- }
34
-
31
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 404))
35
32
  expect { room.history }.to raise_error(HipChat::UnknownRoom)
36
33
  end
37
34
 
38
35
  it "fails when we're not allowed to do so" do
39
- mock(HipChat::Room).get(anything, anything) {
40
- OpenStruct.new(:code => 401)
41
- }
36
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 401))
42
37
 
43
38
  expect { room.history }.to raise_error(HipChat::Unauthorized)
44
39
  end
45
40
 
46
41
  it "fails if we get an unknown response code" do
47
- mock(HipChat::Room).get(anything, anything) {
48
- OpenStruct.new(:code => 403)
49
- }
42
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 403))
50
43
 
51
44
  expect { room.history }.to raise_error(HipChat::Unauthorized)
52
45
  end
@@ -67,25 +60,19 @@ describe "HipChat (API V1)" do
67
60
  end
68
61
 
69
62
  it "fails when the room doesn't exist" do
70
- mock(HipChat::Room).post(anything, anything) {
71
- OpenStruct.new(:code => 404)
72
- }
63
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
73
64
 
74
65
  expect { room.topic "" }.to raise_error(HipChat::UnknownRoom)
75
66
  end
76
67
 
77
68
  it "fails when we're not allowed to do so" do
78
- mock(HipChat::Room).post(anything, anything) {
79
- OpenStruct.new(:code => 401)
80
- }
69
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
81
70
 
82
71
  expect { room.topic "" }.to raise_error(HipChat::Unauthorized)
83
72
  end
84
73
 
85
74
  it "fails if we get an unknown response code" do
86
- mock(HipChat::Room).post(anything, anything) {
87
- OpenStruct.new(:code => 403)
88
- }
75
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 403))
89
76
 
90
77
  expect { room.topic "" }.to raise_error(HipChat::Unauthorized)
91
78
  end
@@ -134,17 +121,13 @@ describe "HipChat (API V1)" do
134
121
  end
135
122
 
136
123
  it "but fails when the room doesn't exist" do
137
- mock(HipChat::Room).post(anything, anything) {
138
- OpenStruct.new(:code => 404)
139
- }
124
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
140
125
 
141
126
  expect { room.send "", "" }.to raise_error(HipChat::UnknownRoom)
142
127
  end
143
128
 
144
129
  it "but fails when we're not allowed to do so" do
145
- mock(HipChat::Room).post(anything, anything) {
146
- OpenStruct.new(:code => 401)
147
- }
130
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
148
131
 
149
132
  expect { room.send "", "" }.to raise_error(HipChat::Unauthorized)
150
133
  end
@@ -154,9 +137,7 @@ describe "HipChat (API V1)" do
154
137
  end
155
138
 
156
139
  it "but fails if we get an unknown response code" do
157
- mock(HipChat::Room).post(anything, anything) {
158
- OpenStruct.new(:code => 403)
159
- }
140
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 403))
160
141
 
161
142
  expect { room.send "", "" }.to raise_error(HipChat::Unauthorized)
162
143
  end
@@ -29,25 +29,19 @@ describe "HipChat (API V2)" do
29
29
  end
30
30
 
31
31
  it "fails when the room doen't exist" do
32
- mock(HipChat::Room).get(anything, anything) {
33
- OpenStruct.new(:code => 404)
34
- }
32
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 404))
35
33
 
36
34
  expect { room.history }.to raise_error(HipChat::UnknownRoom)
37
35
  end
38
36
 
39
37
  it "fails when we're not allowed to do so" do
40
- mock(HipChat::Room).get(anything, anything) {
41
- OpenStruct.new(:code => 401)
42
- }
38
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 401))
43
39
 
44
40
  expect { room.history }.to raise_error(HipChat::Unauthorized)
45
41
  end
46
42
 
47
43
  it "fails if we get an unknown response code" do
48
- mock(HipChat::Room).get(anything, anything) {
49
- OpenStruct.new(:code => 403)
50
- }
44
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 403))
51
45
 
52
46
  expect { room.history }.to raise_error(HipChat::Unauthorized)
53
47
  end
@@ -70,25 +64,19 @@ describe "HipChat (API V2)" do
70
64
  end
71
65
 
72
66
  it "fails when the room doen't exist" do
73
- mock(HipChat::Room).get(anything, anything) {
74
- OpenStruct.new(:code => 404)
75
- }
67
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 404))
76
68
 
77
69
  expect { room.statistics }.to raise_error(HipChat::UnknownRoom)
78
70
  end
79
71
 
80
72
  it "fails when we're not allowed to do so" do
81
- mock(HipChat::Room).get(anything, anything) {
82
- OpenStruct.new(:code => 401)
83
- }
73
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 401))
84
74
 
85
75
  expect { room.statistics }.to raise_error(HipChat::Unauthorized)
86
76
  end
87
77
 
88
78
  it "fails if we get an unknown response code" do
89
- mock(HipChat::Room).get(anything, anything) {
90
- OpenStruct.new(:code => 403)
91
- }
79
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 403))
92
80
 
93
81
  expect { room.statistics }.to raise_error(HipChat::Unauthorized)
94
82
  end
@@ -109,25 +97,19 @@ describe "HipChat (API V2)" do
109
97
  end
110
98
 
111
99
  it "fails when the room doesn't exist" do
112
- mock(HipChat::Room).put(anything, anything) {
113
- OpenStruct.new(:code => 404)
114
- }
100
+ allow(room.class).to receive(:put).with(anything, anything).and_return(OpenStruct.new(:code => 404))
115
101
 
116
102
  expect { room.topic "" }.to raise_error(HipChat::UnknownRoom)
117
103
  end
118
104
 
119
105
  it "fails when we're not allowed to do so" do
120
- mock(HipChat::Room).put(anything, anything) {
121
- OpenStruct.new(:code => 401)
122
- }
106
+ allow(room.class).to receive(:put).with(anything, anything).and_return(OpenStruct.new(:code => 401))
123
107
 
124
108
  expect { room.topic "" }.to raise_error(HipChat::Unauthorized)
125
109
  end
126
110
 
127
111
  it "fails if we get an unknown response code" do
128
- mock(HipChat::Room).put(anything, anything) {
129
- OpenStruct.new(:code => 403)
130
- }
112
+ allow(room.class).to receive(:put).with(anything, anything).and_return(OpenStruct.new(:code => 403))
131
113
 
132
114
  expect { room.topic "" }.to raise_error(HipChat::Unauthorized)
133
115
  end
@@ -142,25 +124,19 @@ describe "HipChat (API V2)" do
142
124
  end
143
125
 
144
126
  it "but fails when the room doesn't exist" do
145
- mock(HipChat::Room).post(anything, anything) {
146
- OpenStruct.new(:code => 404)
147
- }
127
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
148
128
 
149
129
  expect { room.send_message "" }.to raise_error(HipChat::UnknownRoom)
150
130
  end
151
131
 
152
132
  it "but fails when we're not allowed to do so" do
153
- mock(HipChat::Room).post(anything, anything) {
154
- OpenStruct.new(:code => 401)
155
- }
133
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
156
134
 
157
135
  expect { room.send_message "" }.to raise_error(HipChat::Unauthorized)
158
136
  end
159
137
 
160
138
  it "but fails if we get an unknown response code" do
161
- mock(HipChat::Room).post(anything, anything) {
162
- OpenStruct.new(:code => 403)
163
- }
139
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 403))
164
140
 
165
141
  expect { room.send_message "" }.to raise_error(HipChat::Unauthorized)
166
142
  end
@@ -204,17 +180,13 @@ describe "HipChat (API V2)" do
204
180
  end
205
181
 
206
182
  it "but fails when the room doesn't exist" do
207
- mock(HipChat::Room).post(anything, anything) {
208
- OpenStruct.new(:code => 404)
209
- }
183
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
210
184
 
211
185
  expect { room.send "", "" }.to raise_error(HipChat::UnknownRoom)
212
186
  end
213
187
 
214
188
  it "but fails when we're not allowed to do so" do
215
- mock(HipChat::Room).post(anything, anything) {
216
- OpenStruct.new(:code => 401)
217
- }
189
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
218
190
 
219
191
  expect { room.send "", "" }.to raise_error(HipChat::Unauthorized)
220
192
  end
@@ -224,9 +196,7 @@ describe "HipChat (API V2)" do
224
196
  end
225
197
 
226
198
  it "but fails if we get an unknown response code" do
227
- mock(HipChat::Room).post(anything, anything) {
228
- OpenStruct.new(:code => 403)
229
- }
199
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 403))
230
200
 
231
201
  expect { room.send "", "" }.to raise_error(HipChat::Unauthorized)
232
202
  end
@@ -238,36 +208,29 @@ describe "HipChat (API V2)" do
238
208
  it "successfully" do
239
209
  mock_successful_link_share 'Dude', 'Sloth love Chunk!', link
240
210
 
241
- room.share_link("Dude", "Sloth love Chunk!", link).should be_truthy
211
+ expect(room.share_link("Dude", "Sloth love Chunk!", link)).to be_truthy
242
212
  end
243
213
 
244
214
  it "but fails when the room doesn't exist" do
245
- mock(HipChat::Room).post(anything, anything) {
246
- OpenStruct.new(:code => 404)
247
- }
215
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
248
216
 
249
- lambda { room.share_link "", "", link }.should raise_error(HipChat::UnknownRoom)
217
+ expect(lambda { room.share_link "", "", link }).to raise_error(HipChat::UnknownRoom)
250
218
  end
251
219
 
252
220
  it "but fails when we're not allowed to do so" do
253
- mock(HipChat::Room).post(anything, anything) {
254
- OpenStruct.new(:code => 401)
255
- }
221
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
256
222
 
257
- lambda { room.share_link "", "", link }.should raise_error(HipChat::Unauthorized)
223
+ expect(lambda { room.share_link "", "", link }).to raise_error(HipChat::Unauthorized)
258
224
  end
259
225
 
260
226
  it "but fails if the username is more than 15 chars" do
261
- lambda { room.share_link "a very long username here", "a message", link }.should raise_error(HipChat::UsernameTooLong)
227
+ expect(lambda { room.share_link "a very long username here", "a message", link }).to raise_error(HipChat::UsernameTooLong)
262
228
  end
263
229
 
264
230
  it "but fails if we get an unknown response code" do
265
- mock(HipChat::Room).post(anything, anything) {
266
- OpenStruct.new(:code => 403)
267
- }
231
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 403))
268
232
 
269
- lambda { room.share_link "", "", link }.
270
- should raise_error(HipChat::Unauthorized)
233
+ expect(lambda { room.share_link "", "", link }).to raise_error(HipChat::Unauthorized)
271
234
  end
272
235
  end
273
236
 
@@ -286,36 +249,29 @@ describe "HipChat (API V2)" do
286
249
  it "successfully" do
287
250
  mock_successful_file_send 'Dude', 'Hello world', file
288
251
 
289
- room.send_file("Dude", "Hello world", file).should be_truthy
252
+ expect(room.send_file("Dude", "Hello world", file)).to be_truthy
290
253
  end
291
254
 
292
255
  it "but fails when the room doesn't exist" do
293
- mock(HipChat::Room).post(anything, anything) {
294
- OpenStruct.new(:code => 404)
295
- }
256
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
296
257
 
297
- lambda { room.send_file "", "", file }.should raise_error(HipChat::UnknownRoom)
258
+ expect(lambda { room.send_file "", "", file }).to raise_error(HipChat::UnknownRoom)
298
259
  end
299
260
 
300
261
  it "but fails when we're not allowed to do so" do
301
- mock(HipChat::Room).post(anything, anything) {
302
- OpenStruct.new(:code => 401)
303
- }
262
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
304
263
 
305
- lambda { room.send_file "", "", file }.should raise_error(HipChat::Unauthorized)
264
+ expect(lambda { room.send_file "", "", file }).to raise_error(HipChat::Unauthorized)
306
265
  end
307
266
 
308
267
  it "but fails if the username is more than 15 chars" do
309
- lambda { room.send_file "a very long username here", "a message", file }.should raise_error(HipChat::UsernameTooLong)
268
+ expect(lambda { room.send_file "a very long username here", "a message", file }).to raise_error(HipChat::UsernameTooLong)
310
269
  end
311
270
 
312
271
  it "but fails if we get an unknown response code" do
313
- mock(HipChat::Room).post(anything, anything) {
314
- OpenStruct.new(:code => 403)
315
- }
272
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 403))
316
273
 
317
- lambda { room.send_file "", "", file }.
318
- should raise_error(HipChat::Unauthorized)
274
+ expect(lambda { room.send_file "", "", file }).to raise_error(HipChat::Unauthorized)
319
275
  end
320
276
  end
321
277
 
@@ -447,17 +403,13 @@ describe "HipChat (API V2)" do
447
403
  end
448
404
 
449
405
  it "but fails when the user doesn't exist" do
450
- mock(HipChat::User).post(anything, anything) {
451
- OpenStruct.new(:code => 404)
452
- }
406
+ allow(user.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
453
407
 
454
408
  expect { user.send "" }.to raise_error(HipChat::UnknownUser)
455
409
  end
456
410
 
457
411
  it "but fails when we're not allowed to do so" do
458
- mock(HipChat::User).post(anything, anything) {
459
- OpenStruct.new(:code => 401)
460
- }
412
+ allow(user.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
461
413
 
462
414
  expect { user.send "" }.to raise_error(HipChat::Unauthorized)
463
415
  end
@@ -468,7 +420,7 @@ describe "HipChat (API V2)" do
468
420
 
469
421
  it 'successfully returns history' do
470
422
  mock_successful_user_history
471
- user.history.should be_truthy
423
+ expect(user.history).to be_truthy
472
424
  end
473
425
 
474
426
  it 'has allowed params' do
@@ -489,23 +441,19 @@ describe "HipChat (API V2)" do
489
441
  it "successfully with a standard file" do
490
442
  mock_successful_user_send_file 'Equal bytes for everyone', file
491
443
 
492
- user.send_file('Equal bytes for everyone', file).should be_truthy
444
+ expect(user.send_file('Equal bytes for everyone', file)).to be_truthy
493
445
  end
494
446
 
495
447
  it "but fails when the user doesn't exist" do
496
- mock(HipChat::User).post(anything, anything) {
497
- OpenStruct.new(:code => 404)
498
- }
448
+ allow(user.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
499
449
 
500
- lambda { user.send_file "", file }.should raise_error(HipChat::UnknownUser)
450
+ expect(lambda { user.send_file "", file }).to raise_error(HipChat::UnknownUser)
501
451
  end
502
452
 
503
453
  it "but fails when we're not allowed to do so" do
504
- mock(HipChat::User).post(anything, anything) {
505
- OpenStruct.new(:code => 401)
506
- }
454
+ allow(user.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
507
455
 
508
- lambda { user.send_file "", file }.should raise_error(HipChat::Unauthorized)
456
+ expect(lambda { user.send_file "", file }).to raise_error(HipChat::Unauthorized)
509
457
  end
510
458
  end
511
459
 
@@ -519,36 +467,29 @@ describe "HipChat (API V2)" do
519
467
  end
520
468
 
521
469
  it "but fails when the room doesn't exist" do
522
- mock(HipChat::Room).post(anything, anything) {
523
- OpenStruct.new(:code => 404)
524
- }
470
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 404))
525
471
 
526
- lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_enter') }.should raise_error(HipChat::UnknownRoom)
472
+ expect(lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_enter') }).to raise_error(HipChat::UnknownRoom)
527
473
  end
528
474
 
529
475
  it "but fails when we're not allowed to do so" do
530
- mock(HipChat::Room).post(anything, anything) {
531
- OpenStruct.new(:code => 401)
532
- }
476
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 401))
533
477
 
534
- lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_enter') }.should raise_error(HipChat::Unauthorized)
478
+ expect(lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_enter') }).to raise_error(HipChat::Unauthorized)
535
479
  end
536
480
 
537
481
  it "but fails if the url is invalid" do
538
- lambda { room.create_webhook('foo://bar.baz/', 'room_enter') }.should raise_error(HipChat::InvalidUrl)
482
+ expect(lambda { room.create_webhook('foo://bar.baz/', 'room_enter') }).to raise_error(HipChat::InvalidUrl)
539
483
  end
540
484
 
541
485
  it "but fails if the event is invalid" do
542
- lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_vandalize') }.should raise_error(HipChat::InvalidEvent)
486
+ expect(lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_vandalize') }).to raise_error(HipChat::InvalidEvent)
543
487
  end
544
488
 
545
489
  it "but fails if we get an unknown response code" do
546
- mock(HipChat::Room).post(anything, anything) {
547
- OpenStruct.new(:code => 403)
548
- }
490
+ allow(room.class).to receive(:post).with(anything, anything).and_return(OpenStruct.new(:code => 403))
549
491
 
550
- lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_enter') }.
551
- should raise_error(HipChat::Unauthorized)
492
+ expect(lambda { room.create_webhook('https://example.org/hooks/awesome', 'room_enter') }).to raise_error(HipChat::Unauthorized)
552
493
  end
553
494
  end
554
495
 
@@ -562,28 +503,21 @@ describe "HipChat (API V2)" do
562
503
  end
563
504
 
564
505
  it "but fails when the webhook doesn't exist" do
565
- mock(HipChat::Room).delete(anything, anything) {
566
- OpenStruct.new(:code => 404)
567
- }
506
+ allow(room.class).to receive(:delete).with(anything, anything).and_return(OpenStruct.new(:code => 404))
568
507
 
569
- lambda { room.delete_webhook('my_awesome_webhook') }.should raise_error(HipChat::UnknownWebhook)
508
+ expect(lambda { room.delete_webhook('my_awesome_webhook') }).to raise_error(HipChat::UnknownWebhook)
570
509
  end
571
510
 
572
511
  it "but fails when we're not allowed to do so" do
573
- mock(HipChat::Room).delete(anything, anything) {
574
- OpenStruct.new(:code => 401)
575
- }
512
+ allow(room.class).to receive(:delete).with(anything, anything).and_return(OpenStruct.new(:code => 401))
576
513
 
577
- lambda { room.delete_webhook('my_awesome_webhook') }.should raise_error(HipChat::Unauthorized)
514
+ expect(lambda { room.delete_webhook('my_awesome_webhook') }).to raise_error(HipChat::Unauthorized)
578
515
  end
579
516
 
580
517
  it "but fails if we get an unknown response code" do
581
- mock(HipChat::Room).delete(anything, anything) {
582
- OpenStruct.new(:code => 403)
583
- }
518
+ allow(room.class).to receive(:delete).with(anything, anything).and_return(OpenStruct.new(:code => 403))
584
519
 
585
- lambda { room.delete_webhook('my_awesome_webhook') }.
586
- should raise_error(HipChat::Unauthorized)
520
+ expect(lambda { room.delete_webhook('my_awesome_webhook') }).to raise_error(HipChat::Unauthorized)
587
521
  end
588
522
  end
589
523
 
@@ -597,28 +531,21 @@ describe "HipChat (API V2)" do
597
531
  end
598
532
 
599
533
  it "but fails when the room doesn't exist" do
600
- mock(HipChat::Room).get(anything, anything) {
601
- OpenStruct.new(:code => 404)
602
- }
534
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 404))
603
535
 
604
- lambda { room.get_all_webhooks }.should raise_error(HipChat::UnknownRoom)
536
+ expect(lambda { room.get_all_webhooks }).to raise_error(HipChat::UnknownRoom)
605
537
  end
606
538
 
607
539
  it "but fails when we're not allowed to do so" do
608
- mock(HipChat::Room).get(anything, anything) {
609
- OpenStruct.new(:code => 401)
610
- }
540
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 401))
611
541
 
612
- lambda { room.get_all_webhooks }.should raise_error(HipChat::Unauthorized)
542
+ expect(lambda { room.get_all_webhooks }).to raise_error(HipChat::Unauthorized)
613
543
  end
614
544
 
615
545
  it "but fails if we get an unknown response code" do
616
- mock(HipChat::Room).get(anything, anything) {
617
- OpenStruct.new(:code => 403)
618
- }
546
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 403))
619
547
 
620
- lambda { room.get_all_webhooks }.
621
- should raise_error(HipChat::Unauthorized)
548
+ expect(lambda { room.get_all_webhooks }).to raise_error(HipChat::Unauthorized)
622
549
  end
623
550
  end
624
551
 
@@ -632,28 +559,21 @@ describe "HipChat (API V2)" do
632
559
  end
633
560
 
634
561
  it "but fails when the webhook doesn't exist" do
635
- mock(HipChat::Room).get(anything, anything) {
636
- OpenStruct.new(:code => 404)
637
- }
562
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 404))
638
563
 
639
- lambda { room.get_webhook('5678') }.should raise_error(HipChat::UnknownWebhook)
564
+ expect(lambda { room.get_webhook('5678') }).to raise_error(HipChat::UnknownWebhook)
640
565
  end
641
566
 
642
567
  it "but fails when we're not allowed to do so" do
643
- mock(HipChat::Room).get(anything, anything) {
644
- OpenStruct.new(:code => 401)
645
- }
568
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 401))
646
569
 
647
- lambda { room.get_webhook('5678') }.should raise_error(HipChat::Unauthorized)
570
+ expect(lambda { room.get_webhook('5678') }).to raise_error(HipChat::Unauthorized)
648
571
  end
649
572
 
650
573
  it "but fails if we get an unknown response code" do
651
- mock(HipChat::Room).get(anything, anything) {
652
- OpenStruct.new(:code => 403)
653
- }
574
+ allow(room.class).to receive(:get).with(anything, anything).and_return(OpenStruct.new(:code => 403))
654
575
 
655
- lambda { room.get_webhook('5678') }.
656
- should raise_error(HipChat::Unauthorized)
576
+ expect(lambda { room.get_webhook('5678') }).to raise_error(HipChat::Unauthorized)
657
577
  end
658
578
  end
659
579
  end
@@ -2,7 +2,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'hipchat'
4
4
  require 'rspec'
5
- require 'rspec/autorun'
6
5
  require 'json'
7
6
  require 'webmock/rspec'
8
7
 
@@ -13,8 +12,4 @@ rescue LoadError
13
12
  warn 'warning: coveralls gem not found; skipping coverage'
14
13
  end
15
14
 
16
- Dir["./spec/support/**/*.rb"].each {|f| require f}
17
-
18
- RSpec.configure do |config|
19
- config.mock_with :rr
20
- end
15
+ Dir["./spec/support/**/*.rb"].each {|f| require f}
@@ -0,0 +1,2 @@
1
+ import os
2
+ print os.path.dirname(os.path.realpath(__file__))
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hipchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - HipChat/Atlassian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-28 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mimemagic
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rr
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: 1.11.1
75
+ version: 1.13.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: 1.11.1
82
+ version: 1.13.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
@@ -112,28 +112,42 @@ dependencies:
112
112
  name: rdoc
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">"
115
+ - - ! '>'
116
116
  - !ruby/object:Gem::Version
117
117
  version: 2.4.2
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">"
122
+ - - ! '>'
123
123
  - !ruby/object:Gem::Version
124
124
  version: 2.4.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: tins
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 1.6.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 1.6.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: coveralls
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - ">="
143
+ - - ! '>='
130
144
  - !ruby/object:Gem::Version
131
145
  version: '0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - ">="
150
+ - - ! '>='
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  description: Ruby library to interact with HipChat
@@ -143,12 +157,12 @@ executables: []
143
157
  extensions: []
144
158
  extra_rdoc_files: []
145
159
  files:
146
- - ".coveralls.yml"
147
- - ".document"
148
- - ".gitignore"
149
- - ".ruby-gemset"
150
- - ".ruby-version"
151
- - ".travis.yml"
160
+ - .coveralls.yml
161
+ - .document
162
+ - .gitignore
163
+ - .ruby-gemset
164
+ - .ruby-version
165
+ - .travis.yml
152
166
  - Gemfile
153
167
  - LICENSE
154
168
  - README.textile
@@ -175,6 +189,7 @@ files:
175
189
  - spec/spec.opts
176
190
  - spec/spec_helper.rb
177
191
  - spec/support/shared_contexts_for_hipchat.rb
192
+ - tests.py
178
193
  homepage: https://github.com/hipchat/hipchat-rb
179
194
  licenses:
180
195
  - MIT
@@ -185,17 +200,17 @@ require_paths:
185
200
  - lib
186
201
  required_ruby_version: !ruby/object:Gem::Requirement
187
202
  requirements:
188
- - - ">="
203
+ - - ! '>='
189
204
  - !ruby/object:Gem::Version
190
205
  version: 1.9.3
191
206
  required_rubygems_version: !ruby/object:Gem::Requirement
192
207
  requirements:
193
- - - ">="
208
+ - - ! '>='
194
209
  - !ruby/object:Gem::Version
195
210
  version: '0'
196
211
  requirements: []
197
212
  rubyforge_project:
198
- rubygems_version: 2.4.6
213
+ rubygems_version: 2.4.8
199
214
  signing_key:
200
215
  specification_version: 4
201
216
  summary: Ruby library to interact with HipChat