Sha256: f1cb8ce6fe298463ae522e9807557b030c8aab05dc85176dba68ef9c5ad9ef79

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 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: "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
      Ruboty.logger.should_receive(:info).with("a")
      adapter.say(body: "a")
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruboty-1.1.4 spec/ruboty/adapters/shell_spec.rb
ruboty-1.1.3 spec/ruboty/adapters/shell_spec.rb
ruboty-1.1.2 spec/ruboty/adapters/shell_spec.rb
ruboty-1.1.1 spec/ruboty/adapters/shell_spec.rb
ruboty-1.1.0 spec/ruboty/adapters/shell_spec.rb
ruboty-1.0.4 spec/ruboty/adapters/shell_spec.rb
ruboty-1.0.3 spec/ruboty/adapters/shell_spec.rb
ruboty-1.0.2 spec/ruboty/adapters/shell_spec.rb
ruboty-1.0.1 spec/ruboty/adapters/shell_spec.rb
ruboty-1.0.0 spec/ruboty/adapters/shell_spec.rb