Sha256: 8c12773eb107a16fe2afba5e30e461d2f81c271bd7321efa5e4bf37deb870ecb

Contents?: true

Size: 1.3 KB

Versions: 11

Compression:

Stored size: 1.3 KB

Contents

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

    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_test_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_test_calendar]
        expect(c1).to be_instance_of MyTestCalendar
        expect(c1.name).to eq 'my_test_calendar'
        expect(c1.title).to eq 'My Test Calendar'
      end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
timeboss-0.2.5 spec/calendars_spec.rb
timeboss-0.2.4 spec/calendars_spec.rb
timeboss-0.2.3 spec/calendars_spec.rb
timeboss-0.2.2 spec/calendars_spec.rb
timeboss-0.2.1 spec/calendars_spec.rb
timeboss-0.2.0 spec/calendars_spec.rb
timeboss-0.1.1 spec/calendars_spec.rb
timeboss-0.1.0 spec/calendars_spec.rb
timeboss-0.0.10 spec/calendars_spec.rb
timeboss-0.0.9 spec/calendars_spec.rb
timeboss-0.0.8 spec/calendars_spec.rb