Sha256: 0b7e31bfca646e636a02d1a1d1a7b43c281839b737877b03a57aa1e7a597ebad

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

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

module Troo
  module Commands
    describe Default do
      let(:described_class) { Default }
      let(:klass)           { stub(type: :resource_type) }
      let(:id)              {}
      let(:resource)        { stub }
      let(:outcome)         { true }
      let(:decorator)       { stub(name: 'Test') }

      before do
        API::Client.stubs(:perform)
        klass.stubs(:retrieve).returns(resource)
        resource.stubs(:set_default!).returns(outcome)
        resource.stubs(:decorator).returns(decorator)
      end

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

        context 'when the resource exists' do
          it 'sets the default and returns a polite message' do
            subject.must_match(/set as default/)
          end
        end

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

          it 'returns a polite message' do
            subject.must_match(/cannot be found/)
          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/default_test.rb
troo-0.0.11 test/lib/troo/cli/commands/default_test.rb
troo-0.0.10 test/lib/troo/cli/commands/default_test.rb
troo-0.0.9 test/lib/troo/cli/commands/default_test.rb