Sha256: 444b4c08dcfdde996f007caf75394b078382cff24073f0e4a72bf1a081d336d8

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

shared_examples_for 'at_time' do

  describe '#at_time' do

    context 'point object' do

      context 'exactly equal' do
        subject { Post.at_time(Time.zone.parse('2013-12-28 17:00:00')) }
        it { expect(subject.count).to eql(1) }
      end

      context 'not exactly equal' do
        subject { Post.at_time(Time.zone.parse('2013-12-28 17:00:01')) }
        it { expect(subject.count).to eql(0) }
      end
    end

    context 'timespan object' do

      context 'before start time' do
        subject { Event.at_time(Time.zone.parse('2013-12-23 16:59:59')) }
        it { expect(subject.count).to eql(2) }
      end

      context 'at start time' do
        subject { Event.at_time(Time.zone.parse('2013-12-23 17:00:00')) }
        it { expect(subject.count).to eql(3) }
      end

      context 'after start time' do
        subject { Event.at_time(Time.zone.parse('2013-12-23 17:00:01')) }
        it { expect(subject.count).to eql(3) }
      end

      context 'before end time' do
        subject { Event.at_time(Time.zone.parse('2013-11-06 16:59:59')) }
        it { expect(subject.count).to eql(1) }
      end

      context 'at end time' do
        subject { Event.at_time(Time.zone.parse('2013-11-06 17:00:00')) }
        it { expect(subject.count).to eql(0) }
      end

      context 'after end time' do
        subject { Event.at_time(Time.zone.parse('2013-11-06 17:00:01')) }
        it { expect(subject.count).to eql(0) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
by_star-4.0.1 spec/integration/shared/at_time.rb