Sha256: 1a88c544502265e08e42db9c77a049813ded2748cb90b62b4af93e65970125c0

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

shared_examples_for 'by year' do

  describe '#by_year' do

    context 'point-in-time' do
      subject { Post.by_year('2014') }
      its(:count){ should eq 12 }
    end

    context 'timespan' do
      subject { Event.by_year(13) }
      its(:count){ should eq 13 }
    end

    context 'timespan strict' do
      subject { Event.by_year(Date.parse('2014-02-01'), strict: true) }
      its(:count){ should eq 9 }
    end

    context 'with :year option' do

      context 'point-in-time' do
        subject { Post.by_year(year: 2013) }
        its(:count){ should eq 10 }
      end

      context 'timespan' do
        subject { Event.by_year(year: 2014) }
        its(:count){ should eq 14 }
      end

      context 'timespan strict' do
        subject { Event.by_year(year: 2013, strict: true) }
        its(:count){ should eq 8 }
      end
    end

    it 'should be able to use an alternative field' do
      Event.by_year(:field => 'end_time').count.should eq 14
    end

    it 'can use a 2-digit year' do
      Post.by_year(13).count.should eq 10
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
by_star-2.2.1 spec/integration/shared/by_year.rb
by_star-2.2.0 spec/integration/shared/by_year.rb