Sha256: 61fffe1e6d51ebaeebe171d56bc5c04b8be9057901b05f172d51e4966e8b2084

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')

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
balboa-0.1.7 spec/balboa/cli/application_spec.rb
balboa-0.1.6 spec/balboa/cli/application_spec.rb
balboa-0.1.5 spec/balboa/cli/application_spec.rb