Sha256: a188ab61e63c49e0d4536e5721db30227e25251599f07dc0e94464a0e6f62287

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

module TimeBoss
  class Calendar
    describe Day do
      let(:calendar) { instance_double(TimeBoss::Calendar) }
      let(:start_date) { Date.parse('2019-09-30') }
      let(:subject) { described_class.new(calendar, start_date) }

      it 'knows its stuff' do
        expect(subject.start_date).to eq start_date
        expect(subject.end_date).to eq start_date
        expect(subject.to_range).to eq start_date..start_date
      end

      it 'knows its name' do
        expect(subject.name).to eq start_date.to_s
      end

      it 'knows its title' do
        expect(subject.title).to eq 'September 30, 2019'
      end

      it 'can stringify itself' do
        expect(subject.to_s).to eq subject.name
      end

      describe '#index' do
        before(:each) { allow(calendar).to receive(:year_for).with(start_date).and_return double(start_date: start_date - 3) }

        it 'gets its index within the year' do
          expect(subject.index).to eq 4
        end
      end

      describe '#current?' do
        it 'knows when it is' do
          allow(Date).to receive(:today).and_return start_date
          expect(subject).to be_current
        end

        it 'knows when it is not' do
          expect(subject).not_to be_current
        end
      end

      context 'navigation' do
        it 'can get the previous date' do
          result = subject.previous
          expect(result).to be_a described_class
          expect(result.start_date).to eq start_date - 1.day
        end

        it 'can get the next date' do
          result = subject.next
          expect(result).to be_a described_class
          expect(result.start_date).to eq start_date + 1.day
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
timeboss-0.0.9 spec/calendar/day_spec.rb
timeboss-0.0.8 spec/calendar/day_spec.rb
timeboss-0.0.7 spec/calendar/day_spec.rb
timeboss-0.0.6 spec/calendar/day_spec.rb
timeboss-0.0.5 spec/calendar/day_spec.rb