Sha256: ddf2f855856961df9ae6fec428c3618c3538e52bd3807e65c5a03c03168bf352

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Balboa::CLI::Application do
  it 'stores commands to execute later' do
    app = described_class.new('cmd')
    command = double('command', execute: true)

    app.add_command('cmd', command)

    expect(app.execute).to be true
  end

  it 'coerces command_id to string' do
    app = described_class.new(:cmd)
    command = double('command', execute: true)

    app.add_command('cmd', command)

    expect(app.execute).to be true
  end

  it 'coerces command_key to string' do
    app = described_class.new('cmd')
    command = double('command', execute: true)

    app.add_command(:cmd, command)

    expect(app.execute).to be true
  end

  it 'does not swallow errors from executed command' do
    app = described_class.new('cmd')
    command = double
    allow(command).to receive(:execute).and_raise

    app.add_command(:cmd, command)
    
    expect {
      app.execute
    }.to raise_error(RuntimeError)
  end

  it 'raises error when command not found' do
    app = described_class.new('cmd')

    expect {
      app.execute
    }.to raise_error(Balboa::CLI::Application::CommandNotFound)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
balboa-0.1.4 spec/balboa/cli/application_spec.rb
balboa-0.1.3 spec/balboa/cli/application_spec.rb
balboa-0.1.2 spec/balboa/cli/application_spec.rb