Sha256: 63b551a3213de9379aef0690ba3ae3a3fae37ee2c48ff3a76e87bc9089abf061

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'i18n_flow/cli/command_base'

describe I18nFlow::CLI::CommandBase do
  let(:command) { I18nFlow::CLI::CommandBase.new([]) }

  describe '#invoke!' do
    it 'should raise a not implemented error' do
      expect {
        command.invoke!
      }.to raise_error(/implemented/)
    end
  end

  describe '#exit_with_message' do
    let(:message)        { 'a message' }
    let(:message_regexp) { /a message/ }

    context 'With status code of zero' do
      let(:status)  { 0 }

      it 'should print a message to stdout and exit' do
        expect {
          begin
            command.exit_with_message(status, message)
          rescue SystemExit => e
            expect(e.status).to eq(status)
          end
        }.to output(message_regexp).to_stdout
      end
    end

    context 'With status code of non-zero' do
      let(:status)  { 1 }

      it 'should print a message to stderr and exit' do
        expect {
          begin
            command.exit_with_message(status, message)
          rescue SystemExit => e
            expect(e.status).to eq(status)
          end
        }.to output(message_regexp).to_stderr
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
i18n_flow-0.2.3 spec/lib/i18n_flow/cli/command_base_spec.rb
i18n_flow-0.2.2 spec/lib/i18n_flow/cli/command_base_spec.rb
i18n_flow-0.2.1 spec/lib/i18n_flow/cli/command_base_spec.rb
i18n_flow-0.2.0 spec/lib/i18n_flow/cli/command_base_spec.rb
i18n_flow-0.1.0 spec/lib/i18n_flow/cli/command_base_spec.rb