Sha256: 705905e1faf069eccc17a071c4879fce6c73749bab1cbcd873e4dd3b80f3c486

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require "spec_helper"

describe Ruboty::Adapters::Shell do
  before do
    Ruboty.logger.stub(:info)
  end

  let(:adapter) do
    described_class.new(robot)
  end

  let(:robot) do
    Ruboty::Robot.new
  end

  describe "#run" do
    context "with `exit`" do
      it "stops" do
        Readline.stub(readline: "exit")
        adapter.should_receive(:stop).and_call_original
        adapter.run
      end
    end

    context "with `quit`" do
      it "stops" do
        Readline.stub(readline: "quit")
        adapter.should_receive(:stop).and_call_original
        adapter.run
      end
    end

    context "with EOF" do
      it "stops" do
        Readline.stub(readline: nil)
        adapter.should_receive(:stop).and_call_original
        adapter.run
      end
    end

    context "with Inturrupt from console" do
      it "stops" do
        Readline.stub(:readline).and_raise(Interrupt)
        adapter.should_receive(:stop).and_call_original
        adapter.run
      end
    end

    context "without `exit` nor `quit`" do
      it "passes given message to robot" do
        Readline.stub(:readline).and_return("a", "exit")
        robot.should_receive(:receive).with(body: "a", source: described_class::SOURCE)
        adapter.run
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruboty-1.2.2 spec/ruboty/adapters/shell_spec.rb