Sha256: 95c46cb402e69aa4d915991e60bd6977c1bb238cb928f595ab153b5c9c2b4ac8

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

module TimeBoss
  describe Calendars do
    class MyCal < TimeBoss::Calendar
      def initialize
        super(basis: nil)
      end
    end

    TimeBoss::Calendars.register(:my_amazing_calendar, MyCal)

    describe '#all' do
      let(:all) { described_class.all }

      it 'can get a list of all the registered calendars' do
        expect(all).to be_a Array
        expect(all.length).to be > 1
        all.each { |e| expect(e).to be_a described_class::Entry }
      end

      context 'enumerability' do
        it 'can get a list of names' do
          expect(described_class.map(&:name)).to include(:broadcast, :my_amazing_calendar)
        end
      end
    end

    describe '#[]' do
      it 'can return a baked-in calendar' do
        c1 = described_class[:broadcast]
        c2 = described_class[:broadcast]
        expect(c1).to be_instance_of TimeBoss::Calendars::Broadcast
        expect(c1).to be c2

        expect(c1.name).to eq 'broadcast'
        expect(c1.title).to eq 'Broadcast'
      end

      it 'can return a new calendar' do
        c1 = described_class[:my_amazing_calendar]
        expect(c1).to be_instance_of MyCal
        expect(c1.name).to eq 'my_cal'
        expect(c1.title).to eq 'My Cal'
      end

      it 'can graceully give you nothing' do
        expect(described_class[:missing]).to be nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
timeboss-1.0.1 spec/calendars_spec.rb
timeboss-1.0.0 spec/calendars_spec.rb
timeboss-0.3.1 spec/calendars_spec.rb
timeboss-0.3.0 spec/calendars_spec.rb