Sha256: 8648474824eb12e02829872002d2c1f5ef3b3fcfe6ea810684e48f4fd3b0c628

Contents?: true

Size: 764 Bytes

Versions: 3

Compression:

Stored size: 764 Bytes

Contents

require "spec_helper"

include Monocle

describe View do
  describe "since" do
    before do
      50.times do |i|
        create_view(
          :viewable_id => i,
          :viewed_on_start_date => Time.now - i.days,
          :views => rand(100))
      end
    end

    # TODO: Find a decent way to test this.
    it "returns most viewed objects since the given date" do
      View.since(7.days).all.count.should == 8
    end
  end

  describe "all_time" do
    before do
      50.times do |i|
        create_view(
          :viewable_id => i,
          :viewed_on_start_date => Time.now - i.days,
          :views => rand(100))
      end
    end

    it "returns most viewed objects of all time" do
      View.all_time.all.count.should == 10
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
monocle-0.1.1 spec/view_spec.rb
monocle-0.1.0 spec/view_spec.rb
monocle-0.0.1 spec/view_spec.rb