Sha256: e7f8a3681167879a7a68c4da4dc7768cb9b80a6f62efd5ea980b297b70722e85

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

require "spec_helper"

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

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

  let(:robot) do
    Ellen::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: "exit")
        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

  describe "#say" do
    it "shows given message body on stdout" do
      Ellen.logger.should_receive(:info).with("a")
      adapter.say(body: "a")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ellen-0.2.8 spec/ellen/adapters/shell_spec.rb
ellen-0.2.7 spec/ellen/adapters/shell_spec.rb
ellen-0.2.6 spec/ellen/adapters/shell_spec.rb
ellen-0.2.5 spec/ellen/adapters/shell_spec.rb
ellen-0.2.4 spec/ellen/adapters/shell_spec.rb
ellen-0.2.3 spec/ellen/adapters/shell_spec.rb
ellen-0.2.2 spec/ellen/adapters/shell_spec.rb
ellen-0.2.1 spec/ellen/adapters/shell_spec.rb
ellen-0.2.0 spec/ellen/adapters/shell_spec.rb