Sha256: 11f85aa73b98c9b06b27ef4f55ec99bbfa8be6976b06362a38671addd322f9e4

Contents?: true

Size: 984 Bytes

Versions: 7

Compression:

Stored size: 984 Bytes

Contents

require 'spec_helper'

module Almanack::Representation
  describe JSONFeed do

    let(:calendar) { Almanack.calendar }
    let(:parsed_json) { JSON.parse JSONFeed.from(calendar).to_s }

    before do
      Almanack.reset!
    end

    describe ".from" do
      around do |test|
        Timecop.freeze(Time.now, &test)
      end

      it "returns empty event sources by default" do
        expect(parsed_json).to eq({ "eventSources" => [] })
      end

      it "returns event sources" do
        Almanack.config.add_events [
          { title: "Basic event", start_time: Time.now, custom_data: 'present' }
        ]

        expect(parsed_json).to eq({
          "eventSources" => [
            {
              "events" => [
                {
                  "title" => "Basic event",
                  "startTime" => Time.now.iso8601,
                  "customData" => 'present'
                }
              ]
            }
          ]
        })
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
almanack-1.1.0 spec/representation/json_feed_spec.rb
almanack-1.1.0.beta6 spec/representation/json_feed_spec.rb
almanack-1.1.0.beta5 spec/representation/json_feed_spec.rb
almanack-1.1.0.beta4 spec/representation/json_feed_spec.rb
almanack-1.1.0.beta3 spec/representation/json_feed_spec.rb
almanack-1.1.0.beta2 spec/representation/json_feed_spec.rb
almanack-1.1.0.beta1 spec/representation/json_feed_spec.rb