Sha256: a4cd0d6a2080ca7c71c4ebf9a0b713d0062e37ef13c4e5807019816f99b78c34

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

require 'spec_helper'

shared_examples_for "by quarter" do
  describe "by quarter" do
    def posts_count(*args)
      find_posts(*args).count
    end

    def find_posts(*args)
      Post.by_quarter(*args)
    end

    it "should be able to find posts in the current quarter" do
      posts_count.should eql(8)
    end

    it "should be able to find posts in the 1st quarter" do
      posts_count(1).should eql(8)
    end

    it "should be able to find posts in the 1st quarter of last year" do
      posts_count(1, :year => Time.zone.now.year-1).should eql(1)
    end

    it "should be able to use an alternative field" do
      Event.by_quarter(:field => "start_time").size.should eql(3)
    end

    it "should find posts at the last quarter of the year" do
      posts_count(Time.zone.now.end_of_year).should eql(4)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
by_star-2.1.0.beta2 spec/by_star/shared/by_quarter.rb