Sha256: 1f7fa665ec3b70c6e34c844a521d401758cfa16957d3f86c0f99dbc2f1c36e3d

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

context ShellCommand do

  context 'run' do
    it 'must successfully execute "echo".' do
      command = ShellCommand.run "echo -n Hi!"
      command.success?.must_equal(true)
    end

    it 'must give access to the standard output of "echo"' do
      command = ShellCommand.run "echo -n Hi!"
      command.stdout.must_equal("Hi!")
    end

    it 'must give access to the standard error output of "echo"' do
      command = ShellCommand.run "ls /i_do_not_exist"
      command.stderr.empty?.must_equal(false)
    end

    it 'must call a block, if given.' do
      mock = MiniTest::Mock.new
      mock.expect(:ok, nil)

      ShellCommand.run "ls" do |command|
        mock.ok
      end

      mock.verify
    end

    it "must yield a parameter, if asked." do
      ShellCommand.run "ls" do |command|
        command.must_be_instance_of(ShellCommand::Command)
      end
    end

    it 'must raise a ArgumentError if given no arguments.' do
      proc {
        ShellCommand.run
      }.must_raise(ArgumentError)
    end
  end

  context 'run!' do
    it 'must raise a exception when a command fails.' do
      proc {
        ShellCommand.run! "ls /opskddiofjfsiodjf"
      }.must_raise(ShellCommand::Exception)
    end

    it 'must give a Command when a command is successful.' do
      command = ShellCommand.run! "ls"
      command.must_be_instance_of(ShellCommand::Command)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shell_command-0.1.1 test/test_shell_command.rb
shell_command-0.1.0 test/test_shell_command.rb