Sha256: 4fe0b2f05a629124da18e1b23097104d00e524bb292ba465c88f6f598695deae

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 KB

Contents

require_relative '../../../test_helper'

module Troo
  module CLI
    describe Main do
      let(:described_class) { Main }

      describe '#status' do
        before  { Commands::Status.stubs(:dispatch) }

        subject { capture_io { described_class.new.status }.join }

        it 'returns the output of the command' do
          subject.must_match(/Status/)
        end

        it 'returns the last refresh time' do
          subject.must_match(/Last refreshed/)
        end
      end

      describe '#config' do
        subject { capture_io { described_class.new.config }.join }

        it 'returns the current configuration' do
          subject.must_match(/Current configuration/)
        end
      end

      describe '#cleanup' do
        let(:confirm) { "y\n" }

        before { $stdin.stubs(:gets).returns(confirm) }

        subject { capture_io { described_class.new.cleanup }.join }

        context 'when the user confirms the operation' do
          it 'returns the output of the command' do
            subject.must_match(/All local data has been removed/)
          end
        end

        context 'when the user cancels the operation' do
          let(:confirm) { "n\n" }

          it 'returns the output of the command' do
            subject.must_match(/No local data has been removed/)
          end
        end
      end

      describe '#version' do
        subject { capture_io { described_class.new.version }.join }

        it 'returns the output of the command' do
          subject.must_match(/#{Troo::VERSION}/)
        end
      end

      describe '#move' do
        let(:card_id)  {}
        let(:list_id)  {}
        let(:board_id) {}

        subject do
          capture_io do
            described_class.new.move(card_id, list_id, board_id)
          end.join
        end

        it 'returns the output of the command' do
          subject.must_match(/Card cannot be found/)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.12 test/lib/troo/cli/main_test.rb
troo-0.0.11 test/lib/troo/cli/main_test.rb
troo-0.0.10 test/lib/troo/cli/main_test.rb