aboutsummaryrefslogtreecommitdiffstats
path: root/spec/relations/selection_relation_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/relations/selection_relation_spec.rb')
-rw-r--r--spec/relations/selection_relation_spec.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/relations/selection_relation_spec.rb b/spec/relations/selection_relation_spec.rb
index 0cfd55449c..1f8b760272 100644
--- a/spec/relations/selection_relation_spec.rb
+++ b/spec/relations/selection_relation_spec.rb
@@ -8,7 +8,7 @@ describe SelectionRelation do
@predicate2 = LessThanPredicate.new(@relation1[:age], 2)
end
- describe SelectionRelation, '==' do
+ describe '==' do
it "obtains if both the predicate and the relation are identical" do
SelectionRelation.new(@relation1, @predicate1). \
should == SelectionRelation.new(@relation1, @predicate1)
@@ -19,10 +19,22 @@ describe SelectionRelation do
end
end
- describe SelectionRelation, '#initialize' do
+ describe '#initialize' do
it "manufactures nested selection relations if multiple predicates are provided" do
SelectionRelation.new(@relation1, @predicate1, @predicate2). \
should == SelectionRelation.new(SelectionRelation.new(@relation1, @predicate2), @predicate1)
end
end
+
+ describe '#to_sql' do
+ it "manufactures sql with where clause conditions" do
+ SelectionRelation.new(@relation1, @predicate1).to_sql.should == SelectBuilder.new do
+ select :*
+ from :foo
+ where do
+ equals 'foo.id', 'bar.foo_id'
+ end
+ end
+ end
+ end
end \ No newline at end of file