Sha256: a8980a3dec1b88ea7a507860f0e60fd58316842eb8481097553e3f19c561a1ac

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

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

module Troo
  module Commands
    describe ShowComments do
      let(:described_class) { ShowComments }
      let(:type) { :comments }
      let(:id) { '1' }
      let(:default) { false }
      let(:resource) {}
      let(:presenter) { stub }

      before do
        API::Client.stubs(:perform)
        @card = Fabricate.build(:card, default: default)
        Troo::Card.stubs(:retrieve).returns(resource)
        Presenters::Comment.stubs(:new).returns(presenter)
        presenter.stubs(:show).returns(@card.name)
      end

      after { database_cleanup }

      describe '.dispatch' do
        subject { described_class.dispatch(id) }

        context 'when a resource ID is provided' do
          context 'and the resource exists' do
            let(:resource) { @card }

            it 'presents the comments' do
              subject.must_match(/#{@card.name}/)
            end
          end

          context 'but the resource does not exist' do
            it 'returns a polite message' do
              subject.must_match(/Card cannot be found/)
            end
          end
        end

        context 'when a resource ID is not provided' do
          let(:id) {}

          context 'and a default resource is set' do
            let(:default) { true }
            let(:resource) { @card }

            it 'presents the comments' do
              subject.must_match(/#{@card.name}/)
            end
          end

          context 'and a default resource is not set' do
            it 'returns a polite message' do
              subject.must_match(/to set a default card first/)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
troo-0.0.12 test/lib/troo/cli/commands/show/show_comments_test.rb
troo-0.0.11 test/lib/troo/cli/commands/show/show_comments_test.rb
troo-0.0.10 test/lib/troo/cli/commands/show/show_comments_test.rb
troo-0.0.9 test/lib/troo/cli/commands/show/show_comments_test.rb