Sha256: 115b5a751e0b604718255dc87580d11f14a0bf64b2057e19eaf7125c29536a9c

Contents?: true

Size: 955 Bytes

Versions: 3

Compression:

Stored size: 955 Bytes

Contents

require "spec_helper"

describe "Deferred Query" do

  before :all do
    @userlist = []
    10.times do |i|
      u = User.new
      u.name = "Person#{i}"
      u.save!
      @userlist << u
    end
  end

  after :all do
    @userlist.each do |u|
      u.delete!
    end
  end

  it "should be enumerable" do
    for u in User.all
    end
  end

  it "should be able to be limited to a certain number of results" do
    u = User.all
    u.limit = 5
    u.count.should be == 5

    u = User.all :limit => 4
    u.count.should be == 4
  end

  it "should be able to fetch those since a particular time" do
    u = User.all[User.all.count - 1]
    User.all(:since => u.jason_timestamp).each do |i|
      i.jason_timestamp.should be >= u.jason_timestamp
    end
  end

  it "should return the last element" do
    u = User.all
    u.last.should eq(u[-1])
  end

  it "should return the first element" do
    u = User.all
    u.first.should eq(u[0])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
medea-0.7.2 spec/deferred_query_spec.rb
medea-0.7.1 spec/deferred_query_spec.rb
medea-0.7.0 spec/deferred_query_spec.rb