scamp 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +48 -28
- data/examples/bot.rb +27 -21
- data/lib/scamp/action.rb +13 -5
- data/lib/scamp/connection.rb +6 -6
- data/lib/scamp/matcher.rb +29 -6
- data/lib/scamp/messages.rb +31 -0
- data/lib/scamp/rooms.rb +113 -0
- data/lib/scamp/users.rb +7 -15
- data/lib/scamp/version.rb +1 -1
- data/lib/scamp.rb +12 -9
- data/scamp.gemspec +2 -1
- data/spec/lib/scamp_spec.rb +407 -15
- data/spec/spec_helper.rb +7 -1
- metadata +26 -14
- data/lib/scamp/channels.rb +0 -112
data/spec/lib/scamp_spec.rb
CHANGED
@@ -2,11 +2,24 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Scamp do
|
4
4
|
before do
|
5
|
-
@valid_params = {:api_key => "6124d98749365e3db2c9e5b27ca04db6", :subdomain => "oxygen"}
|
5
|
+
@valid_params = {:api_key => "6124d98749365e3db2c9e5b27ca04db6", :subdomain => "oxygen"}
|
6
6
|
@valid_user_cache_data = {123 => {"name" => "foo"}, 456 => {"name" => "bar"}}
|
7
|
-
|
7
|
+
|
8
|
+
# Stub fetch for room data
|
9
|
+
@valid_room_cache_data = {
|
10
|
+
123 => {
|
11
|
+
"id" => 123,
|
12
|
+
"name" => "foo",
|
13
|
+
"users" => []
|
14
|
+
},
|
15
|
+
456 => {
|
16
|
+
"id" => 456,
|
17
|
+
"name" => "bar",
|
18
|
+
"users" => []
|
19
|
+
}
|
20
|
+
}
|
8
21
|
end
|
9
|
-
|
22
|
+
|
10
23
|
describe "#initialize" do
|
11
24
|
it "should work with valid params" do
|
12
25
|
a(Scamp).should be_a(Scamp)
|
@@ -93,32 +106,32 @@ describe Scamp do
|
|
93
106
|
describe "matching" do
|
94
107
|
|
95
108
|
context "with conditions" do
|
96
|
-
it "should limit matches by
|
109
|
+
it "should limit matches by room id" do
|
97
110
|
canary = mock
|
98
111
|
canary.expects(:lives).once
|
99
112
|
canary.expects(:bang).never
|
100
113
|
|
101
114
|
bot = a Scamp
|
102
115
|
bot.behaviour do
|
103
|
-
match("a string", :conditions => {:
|
104
|
-
match("a string", :conditions => {:
|
116
|
+
match("a string", :conditions => {:room => 123}) {canary.lives}
|
117
|
+
match("a string", :conditions => {:room => 456}) {canary.bang}
|
105
118
|
end
|
106
119
|
|
107
120
|
bot.send(:process_message, {:room_id => 123, :body => "a string"})
|
108
121
|
end
|
109
122
|
|
110
|
-
it "should limit matches by
|
123
|
+
it "should limit matches by room name" do
|
111
124
|
canary = mock
|
112
125
|
canary.expects(:lives).once
|
113
126
|
canary.expects(:bang).never
|
114
127
|
|
115
128
|
bot = a Scamp
|
116
129
|
bot.behaviour do
|
117
|
-
match("a string", :conditions => {:
|
118
|
-
match("a string", :conditions => {:
|
130
|
+
match("a string", :conditions => {:room => "foo"}) {canary.lives}
|
131
|
+
match("a string", :conditions => {:room => "bar"}) {canary.bang}
|
119
132
|
end
|
120
133
|
|
121
|
-
bot.
|
134
|
+
bot.room_cache = @valid_room_cache_data
|
122
135
|
|
123
136
|
bot.send(:process_message, {:room_id => 123, :body => "a string"})
|
124
137
|
end
|
@@ -153,18 +166,18 @@ describe Scamp do
|
|
153
166
|
bot.send(:process_message, {:user_id => 123, :body => "a string"})
|
154
167
|
end
|
155
168
|
|
156
|
-
it "should limit matches by
|
169
|
+
it "should limit matches by room and user" do
|
157
170
|
canary = mock
|
158
171
|
canary.expects(:lives).once
|
159
172
|
canary.expects(:bang).never
|
160
173
|
|
161
174
|
bot = a Scamp
|
162
175
|
bot.behaviour do
|
163
|
-
match("a string", :conditions => {:
|
164
|
-
match("a string", :conditions => {:
|
176
|
+
match("a string", :conditions => {:room => 123, :user => 123}) {canary.lives}
|
177
|
+
match("a string", :conditions => {:room => 456, :user => 456}) {canary.bang}
|
165
178
|
end
|
166
179
|
|
167
|
-
bot.
|
180
|
+
bot.room_cache = @valid_room_cache_data
|
168
181
|
bot.user_cache = @valid_user_cache_data
|
169
182
|
bot.send(:process_message, {:room_id => 123, :user_id => 123, :body => "a string"})
|
170
183
|
bot.send(:process_message, {:room_id => 123, :user_id => 456, :body => "a string"})
|
@@ -187,8 +200,33 @@ describe Scamp do
|
|
187
200
|
|
188
201
|
bot.send(:process_message, {:body => "a string"})
|
189
202
|
end
|
203
|
+
|
204
|
+
it "should not match without prefix when required_prefix is true" do
|
205
|
+
canary = mock
|
206
|
+
canary.expects(:bang).never
|
207
|
+
|
208
|
+
bot = a Scamp, :required_prefix => 'Bot: '
|
209
|
+
bot.behaviour do
|
210
|
+
match("a string") {canary.bang}
|
211
|
+
end
|
212
|
+
|
213
|
+
bot.send(:process_message, {:body => "a string"})
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should match with exact prefix when required_prefix is true" do
|
217
|
+
canary = mock
|
218
|
+
canary.expects(:lives).once
|
219
|
+
|
220
|
+
bot = a Scamp, :required_prefix => 'Bot: '
|
221
|
+
bot.behaviour do
|
222
|
+
match("a string") {canary.lives}
|
223
|
+
end
|
224
|
+
|
225
|
+
bot.send(:process_message, {:body => "Bot: a string"})
|
226
|
+
end
|
190
227
|
end
|
191
228
|
|
229
|
+
|
192
230
|
describe "regexes" do
|
193
231
|
it "should match a regex" do
|
194
232
|
canary = mock
|
@@ -236,6 +274,360 @@ describe Scamp do
|
|
236
274
|
|
237
275
|
bot.send(:process_message, {:body => "please match first and the rest of it"})
|
238
276
|
end
|
277
|
+
|
278
|
+
it "should not match without prefix when required_prefix is present" do
|
279
|
+
canary = mock
|
280
|
+
canary.expects(:bang).never
|
281
|
+
|
282
|
+
bot = a Scamp, :required_prefix => /^Bot[\:,\s]+/i
|
283
|
+
bot.behaviour do
|
284
|
+
match(/a string/) {canary.bang}
|
285
|
+
end
|
286
|
+
|
287
|
+
bot.send(:process_message, {:body => "a string"})
|
288
|
+
bot.send(:process_message, {:body => "some kind of a string"})
|
289
|
+
bot.send(:process_message, {:body => "a string!!!"})
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should match with regex prefix when required_prefix is present" do
|
293
|
+
canary = mock
|
294
|
+
canary.expects(:lives).times(4)
|
295
|
+
|
296
|
+
bot = a Scamp, :required_prefix => /^Bot\W{1,2}/i
|
297
|
+
bot.behaviour do
|
298
|
+
match(/a string/) {canary.lives}
|
299
|
+
end
|
300
|
+
|
301
|
+
bot.send(:process_message, {:body => "Bot, a string"})
|
302
|
+
bot.send(:process_message, {:body => "Bot a string"})
|
303
|
+
bot.send(:process_message, {:body => "bot: a string"})
|
304
|
+
bot.send(:process_message, {:body => "Bot: a string oh my!"})
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe "match block" do
|
310
|
+
it "should make the room details available to the action block" do
|
311
|
+
canary = mock
|
312
|
+
canary.expects(:id).with(123)
|
313
|
+
canary.expects(:name).with(@valid_room_cache_data[123]["name"])
|
314
|
+
|
315
|
+
bot = a Scamp
|
316
|
+
bot.behaviour do
|
317
|
+
match("a string") {
|
318
|
+
canary.id(room_id)
|
319
|
+
canary.name(room)
|
320
|
+
}
|
321
|
+
end
|
322
|
+
|
323
|
+
bot.room_cache = @valid_room_cache_data
|
324
|
+
bot.send(:process_message, {:room_id => 123, :body => "a string"})
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should make the speaking user details available to the action block" do
|
328
|
+
canary = mock
|
329
|
+
canary.expects(:id).with(123)
|
330
|
+
canary.expects(:name).with(@valid_user_cache_data[123]["name"])
|
331
|
+
|
332
|
+
bot = a Scamp
|
333
|
+
bot.behaviour do
|
334
|
+
match("a string") {
|
335
|
+
canary.id(user_id)
|
336
|
+
canary.name(user)
|
337
|
+
}
|
338
|
+
end
|
339
|
+
|
340
|
+
bot.user_cache = @valid_user_cache_data
|
341
|
+
bot.send(:process_message, {:user_id => 123, :body => "a string"})
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should make the message said available to the action block" do
|
345
|
+
canary = mock
|
346
|
+
canary.expects(:message).with("Hello world")
|
347
|
+
|
348
|
+
bot = a Scamp
|
349
|
+
bot.behaviour do
|
350
|
+
match("Hello world") {
|
351
|
+
canary.message(message)
|
352
|
+
}
|
353
|
+
end
|
354
|
+
|
355
|
+
bot.send(:process_message, {:body => "Hello world"})
|
356
|
+
end
|
357
|
+
|
358
|
+
it "should provide a command list" do
|
359
|
+
canary = mock
|
360
|
+
canary.expects(:commands).with([["Hello world", {}], ["Hello other world", {:room=>123}], [/match me/, {:user=>123}]])
|
361
|
+
|
362
|
+
bot = a Scamp
|
363
|
+
bot.behaviour do
|
364
|
+
match("Hello world") {
|
365
|
+
canary.commands(command_list)
|
366
|
+
}
|
367
|
+
match("Hello other world", :conditions => {:room => 123}) {}
|
368
|
+
match(/match me/, :conditions => {:user => 123}) {}
|
369
|
+
end
|
370
|
+
|
371
|
+
bot.send(:process_message, {:body => "Hello world"})
|
372
|
+
end
|
373
|
+
|
374
|
+
it "should be able to play a sound to the room the action was triggered in" do
|
375
|
+
bot = a Scamp
|
376
|
+
bot.behaviour do
|
377
|
+
match("Hello world") {
|
378
|
+
play "yeah"
|
379
|
+
}
|
380
|
+
end
|
381
|
+
|
382
|
+
EM.run_block {
|
383
|
+
room_id = 123
|
384
|
+
stub_request(:post, "https://#{@valid_params[:subdomain]}.campfirenow.com/room/#{room_id}/speak.json").
|
385
|
+
with(
|
386
|
+
:body => "{\"message\":{\"body\":\"yeah\",\"type\":\"SoundMessage\"}}",
|
387
|
+
:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}
|
388
|
+
)
|
389
|
+
|
390
|
+
bot.send(:process_message, {:room_id => room_id, :body => "Hello world"})
|
391
|
+
}
|
392
|
+
end
|
393
|
+
|
394
|
+
it "should be able to play a sound to an arbitrary room" do
|
395
|
+
play_room = 456
|
396
|
+
|
397
|
+
bot = a Scamp
|
398
|
+
bot.behaviour do
|
399
|
+
match("Hello world") {
|
400
|
+
play "yeah", play_room
|
401
|
+
}
|
402
|
+
end
|
403
|
+
|
404
|
+
EM.run_block {
|
405
|
+
room_id = 123
|
406
|
+
stub_request(:post, "https://#{@valid_params[:subdomain]}.campfirenow.com/room/#{play_room}/speak.json").
|
407
|
+
with(
|
408
|
+
:body => "{\"message\":{\"body\":\"yeah\",\"type\":\"SoundMessage\"}}",
|
409
|
+
:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}
|
410
|
+
)
|
411
|
+
|
412
|
+
bot.send(:process_message, {:room_id => room_id, :body => "Hello world"})
|
413
|
+
}
|
414
|
+
end
|
415
|
+
|
416
|
+
it "should be able to say a message to the room the action was triggered in" do
|
417
|
+
bot = a Scamp
|
418
|
+
bot.behaviour do
|
419
|
+
match("Hello world") {
|
420
|
+
say "yeah"
|
421
|
+
}
|
422
|
+
end
|
423
|
+
|
424
|
+
EM.run_block {
|
425
|
+
room_id = 123
|
426
|
+
stub_request(:post, "https://#{@valid_params[:subdomain]}.campfirenow.com/room/#{room_id}/speak.json").
|
427
|
+
with(
|
428
|
+
:body => "{\"message\":{\"body\":\"yeah\",\"type\":\"Textmessage\"}}",
|
429
|
+
:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}
|
430
|
+
)
|
431
|
+
|
432
|
+
bot.send(:process_message, {:room_id => room_id, :body => "Hello world"})
|
433
|
+
}
|
434
|
+
end
|
435
|
+
|
436
|
+
it "should be able to say a message to an arbitrary room" do
|
437
|
+
play_room = 456
|
438
|
+
|
439
|
+
bot = a Scamp
|
440
|
+
bot.behaviour do
|
441
|
+
match("Hello world") {
|
442
|
+
say "yeah", play_room
|
443
|
+
}
|
444
|
+
end
|
445
|
+
|
446
|
+
EM.run_block {
|
447
|
+
room_id = 123
|
448
|
+
stub_request(:post, "https://#{@valid_params[:subdomain]}.campfirenow.com/room/#{play_room}/speak.json").
|
449
|
+
with(
|
450
|
+
:body => "{\"message\":{\"body\":\"yeah\",\"type\":\"Textmessage\"}}",
|
451
|
+
:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}
|
452
|
+
)
|
453
|
+
|
454
|
+
bot.send(:process_message, {:room_id => room_id, :body => "Hello world"})
|
455
|
+
}
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
describe "API" do
|
460
|
+
context "user operations" do
|
461
|
+
it "should fetch user data" do
|
462
|
+
bot = a Scamp
|
463
|
+
|
464
|
+
EM.run_block {
|
465
|
+
stub_request(:get, "https://#{@valid_params[:subdomain]}.campfirenow.com/users/123.json").
|
466
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}).
|
467
|
+
to_return(:status => 200, :body => Yajl::Encoder.encode(:user => @valid_user_cache_data[123]), :headers => {})
|
468
|
+
bot.username_for(123)
|
469
|
+
}
|
470
|
+
end
|
471
|
+
|
472
|
+
it "should handle HTTP errors fetching user data" do
|
473
|
+
mock_logger
|
474
|
+
bot = a Scamp
|
475
|
+
|
476
|
+
url = "https://#{@valid_params[:subdomain]}.campfirenow.com/users/123.json"
|
477
|
+
EM.run_block {
|
478
|
+
stub_request(:get, url).
|
479
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}).
|
480
|
+
to_return(:status => 502, :body => "", :headers => {'Content-Type'=>'text/html'})
|
481
|
+
lambda {bot.username_for(123)}.should_not raise_error
|
482
|
+
}
|
483
|
+
logger_output.should =~ /ERROR.*Couldn't fetch user data for user 123 with url #{url}, http response from API was 502/
|
484
|
+
end
|
485
|
+
|
486
|
+
it "should handle network errors fetching user data" do
|
487
|
+
mock_logger
|
488
|
+
bot = a Scamp
|
489
|
+
|
490
|
+
url = "https://#{@valid_params[:subdomain]}.campfirenow.com/users/123.json"
|
491
|
+
EM.run_block {
|
492
|
+
stub_request(:get, url).
|
493
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}).to_timeout
|
494
|
+
lambda {bot.username_for(123)}.should_not raise_error
|
495
|
+
}
|
496
|
+
logger_output.should =~ /ERROR.*Couldn't connect to #{url} to fetch user data for user 123/
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
context "room operations" do
|
501
|
+
before do
|
502
|
+
@room_list_url = "https://#{@valid_params[:subdomain]}.campfirenow.com/rooms.json"
|
503
|
+
@room_url = "https://#{@valid_params[:subdomain]}.campfirenow.com/room/123.json"
|
504
|
+
@stream_url = "https://streaming.campfirenow.com/room/123/live.json"
|
505
|
+
end
|
506
|
+
|
507
|
+
it "should fetch a room list" do
|
508
|
+
mock_logger
|
509
|
+
bot = a Scamp
|
510
|
+
|
511
|
+
EM.run_block {
|
512
|
+
stub_request(:get, @room_list_url).
|
513
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X']}).
|
514
|
+
to_return(:status => 200, :body => Yajl::Encoder.encode(:rooms => @valid_room_cache_data.values), :headers => {})
|
515
|
+
bot.send(:populate_room_list)
|
516
|
+
}
|
517
|
+
logger_output.should =~ /DEBUG.*Fetched room list/
|
518
|
+
end
|
519
|
+
|
520
|
+
it "should handle HTTP errors fetching the room list" do
|
521
|
+
mock_logger
|
522
|
+
bot = a Scamp
|
523
|
+
|
524
|
+
EM.run_block {
|
525
|
+
# stub_request(:get, url).
|
526
|
+
# with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type'=>'application/json'}).
|
527
|
+
# to_return(:status => 502, :body => "", :headers => {'Content-Type'=>'text/html'})
|
528
|
+
stub_request(:get, @room_list_url).
|
529
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X']}).
|
530
|
+
to_return(:status => 502, :body => "", :headers => {'Content-Type'=>'text/html'})
|
531
|
+
lambda {bot.send(:populate_room_list)}.should_not raise_error
|
532
|
+
}
|
533
|
+
logger_output.should =~ /ERROR.*Couldn't fetch room list with url #{@room_list_url}, http response from API was 502/
|
534
|
+
end
|
535
|
+
|
536
|
+
it "should handle network errors fetching the room list" do
|
537
|
+
mock_logger
|
538
|
+
bot = a Scamp
|
539
|
+
EM.run_block {
|
540
|
+
stub_request(:get, @room_list_url).
|
541
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X']}).to_timeout
|
542
|
+
lambda {bot.send(:populate_room_list)}.should_not raise_error
|
543
|
+
}
|
544
|
+
logger_output.should =~ /ERROR.*Couldn't connect to url #{@room_list_url} to fetch room list/
|
545
|
+
end
|
546
|
+
|
547
|
+
it "should fetch individual room data" do
|
548
|
+
mock_logger
|
549
|
+
bot = a Scamp
|
550
|
+
|
551
|
+
EM.run_block {
|
552
|
+
stub_request(:get, @room_url).
|
553
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X']}).
|
554
|
+
to_return(:status => 200, :body => Yajl::Encoder.encode(:room => @valid_room_cache_data[123]), :headers => {})
|
555
|
+
bot.room_name_for(123)
|
556
|
+
}
|
557
|
+
logger_output.should =~ /DEBUG.*Fetched room data for 123/
|
558
|
+
end
|
559
|
+
|
560
|
+
it "should handle HTTP errors fetching individual room data" do
|
561
|
+
mock_logger
|
562
|
+
bot = a Scamp
|
563
|
+
|
564
|
+
EM.run_block {
|
565
|
+
stub_request(:get, @room_url).
|
566
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X']}).
|
567
|
+
to_return(:status => 502, :body => "", :headers => {'Content-Type'=>'text/html'})
|
568
|
+
lambda {bot.room_name_for(123)}.should_not raise_error
|
569
|
+
}
|
570
|
+
logger_output.should =~ /ERROR.*Couldn't fetch room data for room 123 with url #{@room_url}, http response from API was 502/
|
571
|
+
end
|
572
|
+
|
573
|
+
it "should handle network errors fetching individual room data" do
|
574
|
+
mock_logger
|
575
|
+
bot = a Scamp
|
576
|
+
|
577
|
+
EM.run_block {
|
578
|
+
stub_request(:get, @room_url).
|
579
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X']}).to_timeout
|
580
|
+
lambda {bot.room_name_for(123)}.should_not raise_error
|
581
|
+
}
|
582
|
+
logger_output.should =~ /ERROR.*Couldn't connect to #{@room_url} to fetch room data for room 123/
|
583
|
+
end
|
584
|
+
|
585
|
+
it "should stream a room"
|
586
|
+
it "should handle HTTP errors streaming a room"
|
587
|
+
it "should handle network errors streaming a room"
|
588
|
+
end
|
589
|
+
|
590
|
+
context "message operations" do
|
591
|
+
before do
|
592
|
+
@message_post_url = "https://#{@valid_params[:subdomain]}.campfirenow.com/room/123/speak.json"
|
593
|
+
end
|
594
|
+
it "should send a message" do
|
595
|
+
mock_logger
|
596
|
+
bot = a Scamp
|
597
|
+
|
598
|
+
EM.run_block {
|
599
|
+
stub_request(:post, @message_post_url).
|
600
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type' => 'application/json'}).
|
601
|
+
to_return(:status => 200, :body => Yajl::Encoder.encode(:room => @valid_room_cache_data[123]), :headers => {})
|
602
|
+
bot.send(:send_message, 123, "Hi", "Textmessage")
|
603
|
+
}
|
604
|
+
logger_output.should =~ /DEBUG.*Posted message "Hi" to room 123/
|
605
|
+
end
|
606
|
+
|
607
|
+
it "should handle HTTP errors fetching individual room data" do
|
608
|
+
mock_logger
|
609
|
+
bot = a Scamp
|
610
|
+
|
611
|
+
EM.run_block {
|
612
|
+
stub_request(:post, @message_post_url).
|
613
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type' => 'application/json'}).
|
614
|
+
to_return(:status => 502, :body => "", :headers => {'Content-Type'=>'text/html'})
|
615
|
+
lambda {bot.send(:send_message, 123, "Hi", "Textmessage")}.should_not raise_error
|
616
|
+
}
|
617
|
+
logger_output.should =~ /ERROR.*Couldn't post message "Hi" to room 123 using url #{@message_post_url}, http response from the API was 502/
|
618
|
+
end
|
619
|
+
|
620
|
+
it "should handle network errors fetching individual room data" do
|
621
|
+
mock_logger
|
622
|
+
bot = a Scamp
|
623
|
+
|
624
|
+
EM.run_block {
|
625
|
+
stub_request(:post, @message_post_url).
|
626
|
+
with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type' => 'application/json'}).to_timeout
|
627
|
+
lambda {bot.send(:send_message, 123, "Hi", "Textmessage")}.should_not raise_error
|
628
|
+
}
|
629
|
+
logger_output.should =~ /ERROR.*Couldn't connect to #{@message_post_url} to post message "Hi" to room 123/
|
630
|
+
end
|
239
631
|
end
|
240
632
|
end
|
241
633
|
|
@@ -249,7 +641,7 @@ describe Scamp do
|
|
249
641
|
def mock_logger
|
250
642
|
@logger_string = StringIO.new
|
251
643
|
@fake_logger = Logger.new(@logger_string)
|
252
|
-
Scamp.any_instance.
|
644
|
+
Scamp.any_instance.expects(:logger).returns(@fake_logger)
|
253
645
|
end
|
254
646
|
|
255
647
|
# Bleurgh
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152463380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0.beta.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152463380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yajl-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152461660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.8.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152461660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: em-http-request
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152459120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0.beta.4
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152459120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152457780 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.6.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152457780
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mocha
|
60
|
-
requirement: &
|
60
|
+
requirement: &2152454380 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,18 @@ dependencies:
|
|
65
65
|
version: 0.10.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2152454380
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: &2152453060 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.7.6
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2152453060
|
69
80
|
description: Eventmachine based Campfire bot framework
|
70
81
|
email:
|
71
82
|
- will@willj.net
|
@@ -81,15 +92,16 @@ files:
|
|
81
92
|
- examples/bot.rb
|
82
93
|
- lib/scamp.rb
|
83
94
|
- lib/scamp/action.rb
|
84
|
-
- lib/scamp/channels.rb
|
85
95
|
- lib/scamp/connection.rb
|
86
96
|
- lib/scamp/matcher.rb
|
97
|
+
- lib/scamp/messages.rb
|
98
|
+
- lib/scamp/rooms.rb
|
87
99
|
- lib/scamp/users.rb
|
88
100
|
- lib/scamp/version.rb
|
89
101
|
- scamp.gemspec
|
90
102
|
- spec/lib/scamp_spec.rb
|
91
103
|
- spec/spec_helper.rb
|
92
|
-
homepage:
|
104
|
+
homepage: https://github.com/wjessop/Scamp
|
93
105
|
licenses: []
|
94
106
|
post_install_message:
|
95
107
|
rdoc_options: []
|