Sha256: 4fce83bf19651e8b4822a1a1e951dd46482ebe6d60d8561d9fce9c728ba9960f

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

describe Lita::Adapters::Shell do
  let(:robot) do
    robot = double("Robot")
    allow(robot).to receive(:name).and_return("Lita")
    robot
  end

  subject { described_class.new(robot) }

  describe "#run" do
    before { allow(subject).to receive(:puts) }

    it "passes input to the Robot and breaks on an exit message" do
      expect(subject).to receive(:print).with("#{robot.name} > ").twice
      allow($stdin).to receive(:gets).and_return("foo", "exit")
      expect(robot).to receive(:receive).with(an_instance_of(Lita::Message))
      allow(Thread).to receive(:new) { |&block| block.call }
      subject.run
    end
  end

  describe "#send_message" do
    it "prints its input" do
      expect(subject).to receive(:puts)
      expect(subject).to receive(:puts).with("bar")
      subject.send_messages(double("target"), "bar")
    end
  end

  describe "#shut_down" do
    it "outputs a blank line" do
      expect(subject).to receive(:puts)
      subject.shut_down
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-1.0.0 spec/lita/adapters/shell_spec.rb