Permalink
Browse files

Allow compound join commands. Fixes gh-1.

ZNC's stickychan plugin was issuing
  JOIN #foo,#bar
rather than the normal RFC
  JOIN #foo #bar
  • Loading branch information...
1 parent c681400 commit 81754e9789687cad80187fec4313ba900a04d612 @zerowidth zerowidth committed Jul 7, 2011
Showing with 34 additions and 3 deletions.
  1. +1 −0 lib/camper_van/ircd.rb
  2. +33 −3 spec/camper_van/ircd_spec.rb
View
1 lib/camper_van/ircd.rb
@@ -179,6 +179,7 @@ def shutdown
end
handle :join do |args|
+ args = args.map { |args| args.split(",")}.flatten
args.each do |channel|
join_channel channel
end
View
36 spec/camper_van/ircd_spec.rb
@@ -106,9 +106,39 @@ def user(*args)
@server.handle :user => ["nathan", 0, 0, "Nathan"]
end
- # it "connects to the campfire API" do
- # skip "campfire api next!"
- # end
+ context "with a JOIN command" do
+ before :each do
+ @server.campfire = Class.new do
+ def rooms
+ yield [
+ OpenStruct.new(:name => "Test"),
+ OpenStruct.new(:name => "Day Job")
+ ]
+ end
+ end.new
+ @connection.sent.clear
+ end
+
+ it "joins the given room" do
+ @server.handle :join => ["#test"]
+ @server.channels["#test"].must_be_instance_of CamperVan::Channel
+ end
+
+ it "returns an error if the room doesn't exist" do
+ @server.handle :join => ["#foo"]
+ @server.channels["#foo"].must_equal nil
+ @connection.sent.last.must_match /no such.*room/i
+ end
+
+ it "joins multiple channels if given" do
+ @server.handle :join => ["#test,#day_job"]
+ @connection.sent.must_be_empty
+ @server.channels["#test"].must_be_instance_of CamperVan::Channel
+ @server.channels["#day_job"].must_be_instance_of CamperVan::Channel
+ @ser
+ end
+ end
+
end
context "with a MODE command" do

0 comments on commit 81754e9

Please sign in to comment.