Sha256: df033e8ae7899a096c8823acc7c911d6f78d18db97ce7916227614cd971baee3

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'
require 'markdo/models/task_collection'
require 'markdo/ics_exporter'

module Markdo
  describe IcsExporter do
    it 'produces the body of an iCalendar (.ics) file for incomplete tasks with a valid due date' do
      task_collection = TaskCollection.new([
        '- [ ] Task with no tags',
        '- [ ] @due(2016-04-01) Task with tag-style due date',
        '- [ ] @due(2016-06-31) Task with invalid date',
        '- [x] @due(2016-04-01) Completed task with tag-style due date',
      ])
      ics_exporter = IcsExporter.new(task_collection)

      begin
        Date.parse('2016-06-31')
      rescue
        # MRI raises an error, Opal pushes the date to the next valid one.
        invalid_dates_raise_error = true
      end

      if invalid_dates_raise_error
        expect(ics_exporter.to_ics).to eq(<<-ICS)
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Markdo Due Dates
BEGIN:VEVENT
DTSTART;VALUE=DATE:20160401
DTEND;VALUE=DATE:20160401
SUMMARY:Task with tag-style due date
END:VEVENT
END:VCALENDAR
ICS
      else
        expect(ics_exporter.to_ics).to eq(<<-ICS)
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Markdo Due Dates
BEGIN:VEVENT
DTSTART;VALUE=DATE:20160401
DTEND;VALUE=DATE:20160401
SUMMARY:Task with tag-style due date
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20160701
DTEND;VALUE=DATE:20160701
SUMMARY:Task with invalid date
END:VEVENT
END:VCALENDAR
ICS
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
markdo-0.2.0 spec/lib/ics_exporter_spec.rb