Sha256: 0819dfe20a2c497c7cd86375ea1be775ad072a6cd5b9f847274d023abea4f408

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

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

module Troo
  module Commands
    module Refresh
      describe List do
        let(:described_class) { List }
        let(:id) { '1' }
        let(:resource) {}
        let(:retrieved) {}

        before do
          @list = Fabricate.build(:list)
          Retrieval::List.stubs(:retrieve).returns(resource)
          External::List.stubs(:fetch).returns(retrieved)
        end

        after { database_cleanup }

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

          context 'when the resource exists' do
            let(:resource) { @list }
            let(:retrieved) { [@list] }

            context 'and the resource is refreshed' do
              it 'returns a polite message' do
                subject.must_match(/refreshed/)
              end
            end

            context 'and multiple resources are refreshed' do
              let(:retrieved) { [@list, @list] }

              it 'returns a polite message' do
                subject.must_match(/Multiple/)
              end
            end
          end

          context 'when the resource does not exist' do
            let(:resource) {}

            it 'returns a polite message' do
              subject.must_match(/List cannot be found/)
            end
          end

          context 'and the default resource does not exist' do
            let(:id) {}
            let(:resource) {}

            it 'returns a polite message' do
              subject.must_match(/Default list cannot be found/)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 test/lib/troo/commands/refresh/list_test.rb