Sha256: afbf81182c4a13fb20f045d81ebd383e216906033f4e3f64968bebb9232ba6e2

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

describe Ppl::Command::Shell do

  before(:each) do
    @command = Ppl::Command::Shell.new
    @input   = Ppl::Application::Input.new
    @output  = double(Ppl::Application::Output)
  end

  describe "#name" do
    it "should be 'shell'" do
      @command.name.should eq "shell"
    end
  end

  describe "#execute" do
    before(:each) do
      @output.should_receive(:line)
    end
    it "should read a line of input from stdin" do
      Readline.should_receive(:readline)
      @command.execute(@input, @output).should eq true
    end
  end

  describe "#execute" do
    before(:each) do
      @output.should_receive(:line)
    end

    it "should make a system call with the input from stdin" do
      Readline.should_receive(:readline).and_return("email fred")
      Readline.should_receive(:readline).and_return(false)
      Kernel.should_receive(:system) do |command|
        command.should include "email fred"
      end
      @command.execute(@input, @output).should eq true
    end

    it "should exit on ctrl+c" do
      Readline.should_receive(:readline).and_raise(Interrupt)
      @command.execute(@input, @output).should eq false
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ppl-1.5.1 spec/ppl/command/shell_spec.rb
ppl-1.5.0 spec/ppl/command/shell_spec.rb