blob: 261afcaf8ee709ffd01c992f6de5c885db074477 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
describe RangeRelation do
before do
@relation1 = TableRelation.new(:foo)
@relation2 = TableRelation.new(:bar)
@range1 = 1..2
@range2 = 4..9
end
describe '==' do
it "obtains if the relation and range are identical" do
RangeRelation.new(@relation1, @range1).should == RangeRelation.new(@relation1, @range1)
RangeRelation.new(@relation1, @range1).should_not == RangeRelation.new(@relation2, @range1)
RangeRelation.new(@relation1, @range1).should_not == RangeRelation.new(@relation1, @range2)
end
end
describe '#qualify' do
it "manufactures a range relation with a qualified relation and a qualified range" do
pending
end
end
describe '#to_sql' do
it "manufactures sql with limit and offset" do
range_size = @range2.last - @range2.first + 1
range_start = @range2.first
RangeRelation.new(@relation1, @range2).to_sql.to_s.should == SelectBuilder.new do
select do
column :foo, :name
column :foo, :id
end
from :foo
limit range_size
offset range_start
end.to_s
end
end
end
|