aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-02-11 23:09:15 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-02-11 23:09:15 -0800
commit0d70ce37e510c83d5fc42f88b04314f40d87fe96 (patch)
tree03183df1b69ebb31bd5148bc8a9443647348ff3a /spec
parent82cd330dbac31d79e23cc06273321ecbac2b9077 (diff)
downloadrails-0d70ce37e510c83d5fc42f88b04314f40d87fe96.tar.gz
rails-0d70ce37e510c83d5fc42f88b04314f40d87fe96.tar.bz2
rails-0d70ce37e510c83d5fc42f88b04314f40d87fe96.zip
rename substitute to bind since it 'binds' an object to a new relation.
Diffstat (limited to 'spec')
-rw-r--r--spec/active_relation/predicates/binary_spec.rb6
-rw-r--r--spec/active_relation/primitives/attribute_spec.rb8
-rw-r--r--spec/active_relation/primitives/expression_spec.rb8
-rw-r--r--spec/active_relation/relations/compound_spec.rb12
-rw-r--r--spec/active_relation/relations/join_spec.rb2
-rw-r--r--spec/active_relation/relations/rename_spec.rb24
6 files changed, 30 insertions, 30 deletions
diff --git a/spec/active_relation/predicates/binary_spec.rb b/spec/active_relation/predicates/binary_spec.rb
index 5d1e7d1223..599cfa2942 100644
--- a/spec/active_relation/predicates/binary_spec.rb
+++ b/spec/active_relation/predicates/binary_spec.rb
@@ -33,10 +33,10 @@ module ActiveRelation
end
end
- describe '#substitute' do
+ describe '#bind' do
it "distributes over the predicates and attributes" do
- ConcreteBinary.new(@attribute1, @attribute2).substitute(@relation2). \
- should == ConcreteBinary.new(@attribute1.substitute(@relation2), @attribute2.substitute(@relation2))
+ ConcreteBinary.new(@attribute1, @attribute2).bind(@relation2). \
+ should == ConcreteBinary.new(@attribute1.bind(@relation2), @attribute2.bind(@relation2))
end
end
diff --git a/spec/active_relation/primitives/attribute_spec.rb b/spec/active_relation/primitives/attribute_spec.rb
index e79f0c994d..ecc9014658 100644
--- a/spec/active_relation/primitives/attribute_spec.rb
+++ b/spec/active_relation/primitives/attribute_spec.rb
@@ -17,14 +17,14 @@ module ActiveRelation
end
end
- describe '#substitute' do
- it "manufactures an attribute with the relation substituted and self as an ancestor" do
+ describe '#bind' do
+ it "manufactures an attribute with the relation bindd and self as an ancestor" do
derived_relation = @relation.select(@relation[:id].equals(1))
- @attribute.substitute(derived_relation).should == Attribute.new(derived_relation, @attribute.name, nil, @attribute)
+ @attribute.bind(derived_relation).should == Attribute.new(derived_relation, @attribute.name, nil, @attribute)
end
it "returns self if the substituting to the same relation" do
- @attribute.substitute(@relation).should == @attribute
+ @attribute.bind(@relation).should == @attribute
end
end
diff --git a/spec/active_relation/primitives/expression_spec.rb b/spec/active_relation/primitives/expression_spec.rb
index d699dfded0..2ec5130386 100644
--- a/spec/active_relation/primitives/expression_spec.rb
+++ b/spec/active_relation/primitives/expression_spec.rb
@@ -12,14 +12,14 @@ module ActiveRelation
@expression = Expression.new(@attribute, "COUNT")
end
- describe '#substitute' do
- it "manufactures an attribute with a substituted relation and self as the ancestor" do
+ describe '#bind' do
+ it "manufactures an attribute with a bindd relation and self as the ancestor" do
derived_relation = @relation.select(@relation[:id] == 1)
- @expression.substitute(derived_relation).should == Expression.new(@attribute.substitute(derived_relation), "COUNT", nil, @expression)
+ @expression.bind(derived_relation).should == Expression.new(@attribute.bind(derived_relation), "COUNT", nil, @expression)
end
it "returns self if the substituting to the same relation" do
- @expression.substitute(@relation).should == @expression
+ @expression.bind(@relation).should == @expression
end
end
diff --git a/spec/active_relation/relations/compound_spec.rb b/spec/active_relation/relations/compound_spec.rb
index 79ac965e63..bb2919a318 100644
--- a/spec/active_relation/relations/compound_spec.rb
+++ b/spec/active_relation/relations/compound_spec.rb
@@ -14,21 +14,21 @@ module ActiveRelation
describe '#attributes' do
it 'manufactures attributes associated with the compound relation' do
- @compound_relation.attributes.should == @relation.attributes.collect { |a| a.substitute(@compound_relation) }
+ @compound_relation.attributes.should == @relation.attributes.collect { |a| a.bind(@compound_relation) }
end
end
describe '[]' do
describe 'when given a', Symbol do
it 'manufactures attributes associated with the compound relation if the symbol names an attribute within the relation' do
- @compound_relation[:id].should == @relation[:id].substitute(@compound_relation)
+ @compound_relation[:id].should == @relation[:id].bind(@compound_relation)
@compound_relation[:does_not_exist].should be_nil
end
end
describe 'when given an', Attribute do
- it "manufactures a substituted attribute when given an attribute within the relation" do
- @compound_relation[@relation[:id]].should == @relation[:id].substitute(@compound_relation)
+ it "manufactures a bindd attribute when given an attribute within the relation" do
+ @compound_relation[@relation[:id]].should == @relation[:id].bind(@compound_relation)
@compound_relation[@compound_relation[:id]].should == @compound_relation[:id]
pending "test nil"
end
@@ -42,8 +42,8 @@ module ActiveRelation
@compound_relation = ConcreteCompound.new(@nested_relation)
end
- it "manufactures a substituted Expression when given an Expression within the relation" do
- @compound_relation[@nested_expression].should == @nested_relation[@nested_expression].substitute(@compound_relation)
+ it "manufactures a bindd Expression when given an Expression within the relation" do
+ @compound_relation[@nested_expression].should == @nested_relation[@nested_expression].bind(@compound_relation)
@compound_relation[@compound_relation[@expression]].should == @compound_relation[@expression]
@compound_relation[@unprojected_expression].should be_nil
end
diff --git a/spec/active_relation/relations/join_spec.rb b/spec/active_relation/relations/join_spec.rb
index 3b2ad88123..5c86c72a18 100644
--- a/spec/active_relation/relations/join_spec.rb
+++ b/spec/active_relation/relations/join_spec.rb
@@ -40,7 +40,7 @@ module ActiveRelation
it 'combines the attributes of the two relations' do
@join.attributes.should ==
- (@relation1.attributes + @relation2.attributes).collect { |a| a.substitute(@join) }
+ (@relation1.attributes + @relation2.attributes).collect { |a| a.bind(@join) }
end
end
diff --git a/spec/active_relation/relations/rename_spec.rb b/spec/active_relation/relations/rename_spec.rb
index 695e51c191..5a6cecc39e 100644
--- a/spec/active_relation/relations/rename_spec.rb
+++ b/spec/active_relation/relations/rename_spec.rb
@@ -34,22 +34,22 @@ module ActiveRelation
describe 'when given a', Symbol do
it 'indexes attributes by rename if the symbol names an attribute within the relation' do
@renamed_relation[:id].should be_nil
- @renamed_relation[:schmid].should == @relation1[:id].as(:schmid).substitute(@renamed_relation)
+ @renamed_relation[:schmid].should == @relation1[:id].as(:schmid).bind(@renamed_relation)
@renamed_relation[:does_not_exist].should be_nil
end
end
describe 'when given an', Attribute do
- it 'manufactures a substituted and renamed attribute if the attribute is within the relation' do
- @renamed_relation[@relation1[:id]].should == @relation1[:id].as(:schmid).substitute(@renamed_relation)
- @renamed_relation[@relation1[:name]].should == @relation1[:name].substitute(@renamed_relation)
+ it 'manufactures a bindd and renamed attribute if the attribute is within the relation' do
+ @renamed_relation[@relation1[:id]].should == @relation1[:id].as(:schmid).bind(@renamed_relation)
+ @renamed_relation[@relation1[:name]].should == @relation1[:name].bind(@renamed_relation)
@renamed_relation[@renamed_relation[:name]].should == @renamed_relation[:name]
@renamed_relation[@relation2[:id]].should be_nil
end
end
describe 'when given an', Expression do
- it "manufactures a substituted and renamed expression if the expression is within the relation" do
+ it "manufactures a bindd and renamed expression if the expression is within the relation" do
pending
end
end
@@ -60,17 +60,17 @@ module ActiveRelation
end
describe 'when given a', Symbol do
- it 'manufactures a substituted and renamed attribute if the attribute is within the relation' do
+ it 'manufactures a bindd and renamed attribute if the attribute is within the relation' do
@renamed_renamed_relation[:id].should be_nil
@renamed_renamed_relation[:schmid].should be_nil
- @renamed_renamed_relation[:flid].should == @renamed_relation[:schmid].as(:flid).substitute(@renamed_renamed_relation)
+ @renamed_renamed_relation[:flid].should == @renamed_relation[:schmid].as(:flid).bind(@renamed_renamed_relation)
end
end
describe 'when given an', Attribute do
- it "manufactures a substituted and renamed attribute if the attribute is within the relation -- even if the provided attribute derived" do
- @renamed_renamed_relation[@renamed_relation[:schmid]].should == @renamed_relation[:schmid].as(:flid).substitute(@renamed_renamed_relation)
- @renamed_renamed_relation[@relation1[:id]].should == @renamed_relation[:schmid].as(:flid).substitute(@renamed_renamed_relation)
+ it "manufactures a bindd and renamed attribute if the attribute is within the relation -- even if the provided attribute derived" do
+ @renamed_renamed_relation[@renamed_relation[:schmid]].should == @renamed_relation[:schmid].as(:flid).bind(@renamed_renamed_relation)
+ @renamed_renamed_relation[@relation1[:id]].should == @renamed_relation[:schmid].as(:flid).bind(@renamed_renamed_relation)
end
end
@@ -81,8 +81,8 @@ module ActiveRelation
@renamed_relation = Rename.new(@aggregation, @expression => :cnt)
end
- it "manufactures a substituted and renamed expression if the expression is within the relation" do
- @renamed_relation[@expression].should == @aggregation[@expression].as(:cnt).substitute(@renamed_relation)
+ it "manufactures a bindd and renamed expression if the expression is within the relation" do
+ @renamed_relation[@expression].should == @aggregation[@expression].as(:cnt).bind(@renamed_relation)
end
end
end