From d53e6b5e6a9dff2b038841e37d8728ba4766a406 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sat, 22 Feb 2014 20:04:57 -0800 Subject: [PATCH] Add #join and #part. --- lib/lita/adapters/irc.rb | 8 ++++++++ spec/lita/adapters/irc_spec.rb | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/lita/adapters/irc.rb b/lib/lita/adapters/irc.rb index 9688818..548f997 100644 --- a/lib/lita/adapters/irc.rb +++ b/lib/lita/adapters/irc.rb @@ -24,6 +24,14 @@ def run cinch.start end + def join(room_id) + cinch.join(room_id) + end + + def part(room_id) + cinch.part(room_id) + end + def send_messages(target, strings) if target.private_message? user = Cinch::User.new(target.user.name, cinch) diff --git a/spec/lita/adapters/irc_spec.rb b/spec/lita/adapters/irc_spec.rb index c524bd3..fe1412e 100644 --- a/spec/lita/adapters/irc_spec.rb +++ b/spec/lita/adapters/irc_spec.rb @@ -48,6 +48,20 @@ expect(subject.cinch.loggers).not_to be_empty end + describe "#join" do + it "joins a channel" do + expect(subject.cinch).to receive(:join).with("#lita.io") + subject.join("#lita.io") + end + end + + describe "#part" do + it "parts from a channel" do + expect(subject.cinch).to receive(:part).with("#lita.io") + subject.part("#lita.io") + end + end + describe "#run" do it "connects to IRC" do expect(subject.cinch).to receive(:start)