spec/lita/robot_spec.rb in lita-2.7.2 vs spec/lita/robot_spec.rb in lita-3.0.0

- old
+ new

@@ -13,12 +13,12 @@ expect_any_instance_of(described_class).to receive(:trigger).with(:loaded) subject end context "with registered handlers" do - let(:handler1) { double("Handler 1").as_null_object } - let(:handler2) { double("Handler 2").as_null_object } + let(:handler1) { class_double("Lita::Handler", http_routes: [], trigger: nil) } + let(:handler2) { class_double("Lita::Handler", http_routes: [], trigger: nil) } before do allow(Lita).to receive(:handlers).and_return([handler1, handler2]) end @@ -38,15 +38,16 @@ end end end describe "#run" do - let(:thread) { double("Thread", :abort_on_exception= => true, join: nil) } + let(:thread) { instance_double("Thread", :abort_on_exception= => true, join: nil) } before do allow_any_instance_of(Lita::Adapters::Shell).to receive(:run) - allow_any_instance_of(Thin::Server).to receive(:start) + allow_any_instance_of(Puma::Server).to receive(:run) + allow_any_instance_of(Puma::Server).to receive(:add_tcp_listener) allow(Thread).to receive(:new) do |&block| block.call thread end @@ -56,43 +57,51 @@ expect_any_instance_of(Lita::Adapters::Shell).to receive(:run) subject.run end it "starts the web server" do - expect_any_instance_of(Thin::Server).to receive(:start) + expect_any_instance_of(Puma::Server).to receive(:run) subject.run end - it "doesn't silence thin if config.http.debug is true" do - Lita.config.http.debug = true - expect_any_instance_of(Thin::Server).not_to receive(:silent=) - subject.run - end - it "rescues interrupts and calls #shut_down" do allow_any_instance_of( Lita::Adapters::Shell ).to receive(:run).and_raise(Interrupt) expect_any_instance_of(Lita::Adapters::Shell).to receive(:shut_down) subject.run end end + describe "#join" do + it "delegates to the adapter" do + expect_any_instance_of(Lita::Adapters::Shell).to receive(:join).with("#lita.io") + subject.join("#lita.io") + end + end + + describe "#part" do + it "delegates to the adapter" do + expect_any_instance_of(Lita::Adapters::Shell).to receive(:part).with("#lita.io") + subject.part("#lita.io") + end + end + describe "#send_message" do - let(:source) { double("Source") } + let(:source) { instance_double("Lita::Source") } it "delegates to the adapter" do expect_any_instance_of( Lita::Adapters::Shell ).to receive(:send_messages).with( - source, ["foo", "bar"] + source, %w(foo bar) ) subject.send_messages(source, "foo", "bar") end end describe "#set_topic" do - let(:source) { double("Source") } + let(:source) { instance_double("Lita::Source") } it "delegates to the adapter" do expect_any_instance_of(Lita::Adapters::Shell).to receive(:set_topic).with( source, "New topic"