aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/active_relation/integration/scratch_spec.rb16
-rw-r--r--spec/active_relation/predicates/binary_predicate_spec.rb19
-rw-r--r--spec/active_relation/relations/attribute_spec.rb15
-rw-r--r--spec/active_relation/relations/deletion_relation_spec.rb24
-rw-r--r--spec/active_relation/relations/insertion_relation_spec.rb31
-rw-r--r--spec/active_relation/relations/join_relation_spec.rb32
-rw-r--r--spec/active_relation/relations/order_relation_spec.rb25
-rw-r--r--spec/active_relation/relations/projection_relation_spec.rb10
-rw-r--r--spec/active_relation/relations/range_relation_spec.rb25
-rw-r--r--spec/active_relation/relations/relation_spec.rb24
-rw-r--r--spec/active_relation/relations/rename_relation_spec.rb11
-rw-r--r--spec/active_relation/relations/selection_relation_spec.rb37
-rw-r--r--spec/active_relation/relations/table_relation_spec.rb11
-rw-r--r--spec/active_relation/sql_builder/conditions_spec.rb18
-rw-r--r--spec/active_relation/sql_builder/delete_builder_spec.rb22
-rw-r--r--spec/active_relation/sql_builder/insert_builder_spec.rb24
-rw-r--r--spec/active_relation/sql_builder/select_builder_spec.rb148
17 files changed, 95 insertions, 397 deletions
diff --git a/spec/active_relation/integration/scratch_spec.rb b/spec/active_relation/integration/scratch_spec.rb
index fba587e4ba..93d332eea7 100644
--- a/spec/active_relation/integration/scratch_spec.rb
+++ b/spec/active_relation/integration/scratch_spec.rb
@@ -71,7 +71,7 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
# the 'project' operator limits the columns that come back from the query.
# Note how all the operators are compositional: 'project' is applied to a query
# that previously had been joined and selected.
- user_photos.project(*@photos.attributes).to_s.should be_like("""
+ user_photos.project(*@photos.attributes).to_sql.should be_like("""
SELECT `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
FROM `users`
LEFT OUTER JOIN `photos`
@@ -86,7 +86,7 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
it 'generates the query for User.has_many :cameras :through => :photos' do
# note, again, the compositionality of the operators:
user_cameras = photo_belongs_to_camera(user_has_many_photos(@user))
- user_cameras.project(*@cameras.attributes).to_s.should be_like("""
+ user_cameras.project(*@cameras.attributes).to_sql.should be_like("""
SELECT `cameras`.`id`
FROM `users`
LEFT OUTER JOIN `photos`
@@ -101,7 +101,7 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
it 'generates the query for an eager join for a collection using the same logic as
for an association on an individual row' do
users_cameras = photo_belongs_to_camera(user_has_many_photos(@users))
- users_cameras.to_s.should be_like("""
+ users_cameras.to_sql.should be_like("""
SELECT `users`.`name`, `users`.`id`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`, `cameras`.`id`
FROM `users`
LEFT OUTER JOIN `photos`
@@ -113,7 +113,7 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
it 'is trivial to disambiguate columns' do
users_cameras = photo_belongs_to_camera(user_has_many_photos(@users)).qualify
- users_cameras.to_s.should be_like("""
+ users_cameras.to_sql.should be_like("""
SELECT `users`.`name` AS 'users.name', `users`.`id` AS 'users.id', `photos`.`id` AS 'photos.id', `photos`.`user_id` AS 'photos.user_id', `photos`.`camera_id` AS 'photos.camera_id', `cameras`.`id` AS 'cameras.id'
FROM `users`
LEFT OUTER JOIN `photos`
@@ -124,13 +124,13 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
end
it 'allows arbitrary sql to be passed through' do
- (@users << @photos).on("asdf").to_s.should be_like("""
+ (@users << @photos).on("asdf").to_sql.should be_like("""
SELECT `users`.`name`, `users`.`id`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
FROM `users`
LEFT OUTER JOIN `photos`
ON asdf
""")
- @users.select("asdf").to_s.should be_like("""
+ @users.select("asdf").to_sql.should be_like("""
SELECT `users`.`name`, `users`.`id`
FROM `users`
WHERE asdf
@@ -139,7 +139,7 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
describe 'write operations' do
it 'generates the query for user.destroy' do
- @user.delete.to_s.should be_like("""
+ @user.delete.to_sql.should be_like("""
DELETE
FROM `users`
WHERE `users`.`id` = 1
@@ -147,7 +147,7 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
end
it 'generates an efficient query for two User.creates -- UnitOfWork is within reach!' do
- @users.insert(@users[:name] => "humpty").insert(@users[:name] => "dumpty").to_s.should be_like("""
+ @users.insert(@users[:name] => "humpty").insert(@users[:name] => "dumpty").to_sql.should be_like("""
INSERT
INTO `users`
(`users`.`name`) VALUES ('humpty'), ('dumpty')
diff --git a/spec/active_relation/predicates/binary_predicate_spec.rb b/spec/active_relation/predicates/binary_predicate_spec.rb
index 5de559df41..0bddae8491 100644
--- a/spec/active_relation/predicates/binary_predicate_spec.rb
+++ b/spec/active_relation/predicates/binary_predicate_spec.rb
@@ -7,18 +7,12 @@ describe BinaryPredicate do
@attribute1 = Attribute.new(@relation1, :name1)
@attribute2 = Attribute.new(@relation2, :name2)
class ConcreteBinaryPredicate < BinaryPredicate
- def predicate_name
- :equals
+ def predicate_sql
+ "<=>"
end
end
end
- describe '#initialize' do
- it "requires that both columns come from the same relation" do
- pending
- end
- end
-
describe '==' do
it "obtains if attribute1 and attribute2 are identical" do
BinaryPredicate.new(@attribute1, @attribute2).should == BinaryPredicate.new(@attribute1, @attribute2)
@@ -40,12 +34,9 @@ describe BinaryPredicate do
describe '#to_sql' do
it 'manufactures correct sql' do
- ConcreteBinaryPredicate.new(@attribute1, @attribute2).to_sql.should == ConditionsBuilder.new do
- equals do
- column :foo, :name1
- column :bar, :name2
- end
- end
+ ConcreteBinaryPredicate.new(@attribute1, @attribute2).to_sql.should be_like("""
+ `foo`.`name1` <=> `bar`.`name2`
+ """)
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/attribute_spec.rb b/spec/active_relation/relations/attribute_spec.rb
index 68ff147ab5..4154a91b85 100644
--- a/spec/active_relation/relations/attribute_spec.rb
+++ b/spec/active_relation/relations/attribute_spec.rb
@@ -8,12 +8,7 @@ describe Attribute do
describe '#alias' do
it "manufactures an aliased attributed" do
- pending
- end
-
- it "should be renamed to #alias!" do
- pending
- @relation1.alias
+ @relation1[:id].alias(:alias).should == Attribute.new(@relation1, :id, :alias)
end
end
@@ -79,12 +74,4 @@ describe Attribute do
end
end
end
-
- describe '#to_sql' do
- it "manufactures a column" do
- Attribute.new(@relation1, :name, :alias).to_sql.should == SelectsBuilder.new do
- column :foo, :name, :alias
- end
- end
- end
end
diff --git a/spec/active_relation/relations/deletion_relation_spec.rb b/spec/active_relation/relations/deletion_relation_spec.rb
index 4f75a261f4..5e8c5137b2 100644
--- a/spec/active_relation/relations/deletion_relation_spec.rb
+++ b/spec/active_relation/relations/deletion_relation_spec.rb
@@ -6,17 +6,19 @@ describe DeletionRelation do
end
describe '#to_sql' do
- it 'manufactures sql deleting the relation' do
- DeletionRelation.new(@relation.select(@relation[:id] == 1)).to_sql.to_s.should == DeleteBuilder.new do
- delete
- from :users
- where do
- equals do
- column :users, :id
- value 1
- end
- end
- end.to_s
+ it 'manufactures sql deleting a table relation' do
+ DeletionRelation.new(@relation).to_sql.should be_like("""
+ DELETE
+ FROM `users`
+ """)
+ end
+
+ it 'manufactures sql deleting a selection relation' do
+ DeletionRelation.new(@relation.select(@relation[:id] == 1)).to_sql.should be_like("""
+ DELETE
+ FROM `users`
+ WHERE `users`.`id` = 1
+ """)
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/insertion_relation_spec.rb b/spec/active_relation/relations/insertion_relation_spec.rb
index 6bafabb473..177918a94a 100644
--- a/spec/active_relation/relations/insertion_relation_spec.rb
+++ b/spec/active_relation/relations/insertion_relation_spec.rb
@@ -7,31 +7,20 @@ describe InsertionRelation do
describe '#to_sql' do
it 'manufactures sql inserting the data for one item' do
- InsertionRelation.new(@relation, @relation[:name] => "nick").to_sql.should == InsertBuilder.new do
- insert
- into :users
- columns do
- column :users, :name
- end
- values do
- row "nick"
- end
- end
+ InsertionRelation.new(@relation, @relation[:name] => "nick").to_sql.should be_like("""
+ INSERT
+ INTO `users`
+ (`users`.`name`) VALUES ('nick')
+ """)
end
it 'manufactures sql inserting the data for multiple items' do
nested_insertion = InsertionRelation.new(@relation, @relation[:name] => "cobra")
- InsertionRelation.new(nested_insertion, nested_insertion[:name] => "commander").to_sql.to_s.should == InsertBuilder.new do
- insert
- into :users
- columns do
- column :users, :name
- end
- values do
- row "cobra"
- row "commander"
- end
- end.to_s
+ InsertionRelation.new(nested_insertion, nested_insertion[:name] => "commander").to_sql.should be_like("""
+ INSERT
+ INTO `users`
+ (`users`.`name`) VALUES ('cobra'), ('commander')
+ """)
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/join_relation_spec.rb b/spec/active_relation/relations/join_relation_spec.rb
index d0be270837..3e60cc4c34 100644
--- a/spec/active_relation/relations/join_relation_spec.rb
+++ b/spec/active_relation/relations/join_relation_spec.rb
@@ -27,33 +27,17 @@ describe JoinRelation do
describe '#to_sql' do
before do
- @relation1 = @relation1.select(@relation1[:id] == @relation2[:foo_id])
+ @relation1 = @relation1.select(@relation1[:id] == 1)
end
it 'manufactures sql joining the two tables on the predicate, merging the selects' do
- InnerJoinRelation.new(@relation1, @relation2, @predicate).to_s.should == SelectBuilder.new do
- select do
- column :foo, :name
- column :foo, :id
- column :bar, :name
- column :bar, :foo_id
- column :bar, :id
- end
- from :foo do
- inner_join :bar do
- equals do
- column :foo, :id
- column :bar, :id
- end
- end
- end
- where do
- equals do
- column :foo, :id
- column :bar, :foo_id
- end
- end
- end.to_s
+ InnerJoinRelation.new(@relation1, @relation2, @predicate).to_sql.should be_like("""
+ SELECT `foo`.`name`, `foo`.`id`, `bar`.`name`, `bar`.`foo_id`, `bar`.`id`
+ FROM `foo`
+ INNER JOIN `bar` ON `foo`.`id` = `bar`.`id`
+ WHERE
+ `foo`.`id` = 1
+ """)
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/order_relation_spec.rb b/spec/active_relation/relations/order_relation_spec.rb
index 17f730b564..8655780c37 100644
--- a/spec/active_relation/relations/order_relation_spec.rb
+++ b/spec/active_relation/relations/order_relation_spec.rb
@@ -7,15 +7,7 @@ describe OrderRelation do
@attribute1 = @relation1[:id]
@attribute2 = @relation2[:id]
end
-
- describe '==' do
- it "obtains if the relation and attributes are identical" do
- OrderRelation.new(@relation1, @attribute1, @attribute2).should == OrderRelation.new(@relation1, @attribute1, @attribute2)
- OrderRelation.new(@relation1, @attribute1).should_not == OrderRelation.new(@relation2, @attribute1)
- OrderRelation.new(@relation1, @attribute1, @attribute2).should_not == OrderRelation.new(@relation1, @attribute2, @attribute1)
- end
- end
-
+
describe '#qualify' do
it "distributes over the relation and attributes" do
OrderRelation.new(@relation1, @attribute1).qualify. \
@@ -25,16 +17,11 @@ describe OrderRelation do
describe '#to_sql' do
it "manufactures sql with an order clause" do
- OrderRelation.new(@relation1, @attribute1).to_s.should == SelectBuilder.new do
- select do
- column :foo, :name
- column :foo, :id
- end
- from :foo
- order_by do
- column :foo, :id
- end
- end.to_s
+ OrderRelation.new(@relation1, @attribute1).to_sql.should be_like("""
+ SELECT `foo`.`name`, `foo`.`id`
+ FROM `foo`
+ ORDER BY `foo`.`id`
+ """)
end
end
diff --git a/spec/active_relation/relations/projection_relation_spec.rb b/spec/active_relation/relations/projection_relation_spec.rb
index 164c485761..77722a17c5 100644
--- a/spec/active_relation/relations/projection_relation_spec.rb
+++ b/spec/active_relation/relations/projection_relation_spec.rb
@@ -25,12 +25,10 @@ describe ProjectionRelation do
describe '#to_sql' do
it "manufactures sql with a limited select clause" do
- ProjectionRelation.new(@relation1, @attribute1).to_s.should == SelectBuilder.new do
- select do
- column :foo, :id
- end
- from :foo
- end.to_s
+ ProjectionRelation.new(@relation1, @attribute1).to_sql.should be_like("""
+ SELECT `foo`.`id`
+ FROM `foo`
+ """)
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/range_relation_spec.rb b/spec/active_relation/relations/range_relation_spec.rb
index ac9f887d9b..67e2b0d164 100644
--- a/spec/active_relation/relations/range_relation_spec.rb
+++ b/spec/active_relation/relations/range_relation_spec.rb
@@ -7,15 +7,7 @@ describe RangeRelation do
@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 "distributes over the relation and attributes" do
pending
@@ -26,15 +18,12 @@ describe RangeRelation 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_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
+ RangeRelation.new(@relation1, @range2).to_s.should be_like("""
+ SELECT `foo`.`name`, `foo`.`id`
+ FROM `foo`
+ LIMIT #{range_size}
+ OFFSET #{range_start}
+ """)
end
end
diff --git a/spec/active_relation/relations/relation_spec.rb b/spec/active_relation/relations/relation_spec.rb
index 9ed42a98cb..5d7c40a530 100644
--- a/spec/active_relation/relations/relation_spec.rb
+++ b/spec/active_relation/relations/relation_spec.rb
@@ -10,17 +10,17 @@ describe Relation do
describe '[]' do
it "manufactures an attribute when given a symbol" do
- @relation1[:id].should be_eql(Attribute.new(@relation1, :id))
+ @relation1[:id].should be_kind_of(Attribute)
end
it "manufactures a range relation when given a range" do
- @relation1[1..2].should == RangeRelation.new(@relation1, 1..2)
+ @relation1[1..2].should be_kind_of(RangeRelation)
end
end
describe '#include?' do
it "manufactures an inclusion predicate" do
- @relation1.include?(@attribute1).should == RelationInclusionPredicate.new(@attribute1, @relation1)
+ @relation1.include?(@attribute1).should be_kind_of(RelationInclusionPredicate)
end
end
@@ -28,13 +28,13 @@ describe Relation do
describe 'joins' do
describe '<=>' do
it "manufactures an inner join operation between those two relations" do
- (@relation1 <=> @relation2).should == InnerJoinOperation.new(@relation1, @relation2)
+ (@relation1 <=> @relation2).should be_kind_of(InnerJoinOperation)
end
end
describe '<<' do
it "manufactures a left outer join operation between those two relations" do
- (@relation1 << @relation2).should == LeftOuterJoinOperation.new(@relation1, @relation2)
+ (@relation1 << @relation2).should be_kind_of(LeftOuterJoinOperation)
end
end
end
@@ -45,13 +45,13 @@ describe Relation do
end
it "manufactures a projection relation" do
- @relation1.project(@attribute1, @attribute2).should == ProjectionRelation.new(@relation1, @attribute1, @attribute2)
+ @relation1.project(@attribute1, @attribute2).should be_kind_of(ProjectionRelation)
end
end
describe '#rename' do
it "manufactures a rename relation" do
- @relation1.rename(@attribute1, :foo).should == RenameRelation.new(@relation1, @attribute1 => :foo)
+ @relation1.rename(@attribute1, :foo).should be_kind_of(RenameRelation)
end
end
@@ -61,17 +61,17 @@ describe Relation do
end
it "manufactures a selection relation" do
- @relation1.select(@predicate).should == SelectionRelation.new(@relation1, @predicate)
+ @relation1.select(@predicate).should be_kind_of(SelectionRelation)
end
it "accepts arbitrary strings" do
- @relation1.select("arbitrary").should == SelectionRelation.new(@relation1, "arbitrary")
+ @relation1.select("arbitrary").should be_kind_of(SelectionRelation)
end
end
describe '#order' do
it "manufactures an order relation" do
- @relation1.order(@attribute1, @attribute2).should == OrderRelation.new(@relation1, @attribute1, @attribute2)
+ @relation1.order(@attribute1, @attribute2).should be_kind_of(OrderRelation)
end
end
end
@@ -79,13 +79,13 @@ describe Relation do
describe 'write operations' do
describe '#delete' do
it 'manufactures a deletion relation' do
- @relation1.delete.should == DeletionRelation.new(@relation1)
+ @relation1.delete.should be_kind_of(DeletionRelation)
end
end
describe '#insert' do
it 'manufactures an insertion relation' do
- @relation1.insert(tuple = {:id => 1}).should == InsertionRelation.new(@relation1, tuple)
+ @relation1.insert(record = {:id => 1}).should be_kind_of(InsertionRelation)
end
end
end
diff --git a/spec/active_relation/relations/rename_relation_spec.rb b/spec/active_relation/relations/rename_relation_spec.rb
index 00a93d10ac..664e9c6145 100644
--- a/spec/active_relation/relations/rename_relation_spec.rb
+++ b/spec/active_relation/relations/rename_relation_spec.rb
@@ -52,13 +52,10 @@ describe RenameRelation do
describe '#to_sql' do
it 'manufactures sql aliasing the attribute' do
- @renamed_relation.to_s.should == SelectBuilder.new do
- select do
- column :foo, :name
- column :foo, :id, :schmid
- end
- from :foo
- end.to_s
+ @renamed_relation.to_sql.should be_like("""
+ SELECT `foo`.`name`, `foo`.`id` AS 'schmid'
+ FROM `foo`
+ """)
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/selection_relation_spec.rb b/spec/active_relation/relations/selection_relation_spec.rb
index c4aadc807b..ac1f227c67 100644
--- a/spec/active_relation/relations/selection_relation_spec.rb
+++ b/spec/active_relation/relations/selection_relation_spec.rb
@@ -8,17 +8,6 @@ describe SelectionRelation do
@predicate2 = LessThanPredicate.new(@relation1[:age], 2)
end
- describe '==' do
- it "obtains if both the predicate and the relation are identical" do
- SelectionRelation.new(@relation1, @predicate1). \
- should == SelectionRelation.new(@relation1, @predicate1)
- SelectionRelation.new(@relation1, @predicate1). \
- should_not == SelectionRelation.new(@relation2, @predicate1)
- SelectionRelation.new(@relation1, @predicate1). \
- should_not == SelectionRelation.new(@relation1, @predicate2)
- end
- end
-
describe '#initialize' do
it "manufactures nested selection relations if multiple predicates are provided" do
SelectionRelation.new(@relation1, @predicate1, @predicate2). \
@@ -35,19 +24,19 @@ describe SelectionRelation do
describe '#to_sql' do
it "manufactures sql with where clause conditions" do
- SelectionRelation.new(@relation1, @predicate1).to_s.should == SelectBuilder.new do
- select do
- column :foo, :name
- column :foo, :id
- end
- from :foo
- where do
- equals do
- column :foo, :id
- column :bar, :foo_id
- end
- end
- end.to_s
+ SelectionRelation.new(@relation1, @predicate1).to_sql.should be_like("""
+ SELECT `foo`.`name`, `foo`.`id`
+ FROM `foo`
+ WHERE `foo`.`id` = `bar`.`foo_id`
+ """)
+ end
+
+ it "allows arbitrary sql" do
+ SelectionRelation.new(@relation1, "asdf").to_sql.should be_like("""
+ SELECT `foo`.`name`, `foo`.`id`
+ FROM `foo`
+ WHERE asdf
+ """)
end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/table_relation_spec.rb b/spec/active_relation/relations/table_relation_spec.rb
index c943fe6c92..79e9610e1b 100644
--- a/spec/active_relation/relations/table_relation_spec.rb
+++ b/spec/active_relation/relations/table_relation_spec.rb
@@ -7,13 +7,10 @@ describe TableRelation do
describe '#to_sql' do
it "returns a simple SELECT query" do
- @relation.to_sql.should == SelectBuilder.new do |s|
- select do
- column :users, :name
- column :users, :id
- end
- from :users
- end
+ @relation.to_sql.should be_like("""
+ SELECT `users`.`name`, `users`.`id`
+ FROM `users`
+ """)
end
end
diff --git a/spec/active_relation/sql_builder/conditions_spec.rb b/spec/active_relation/sql_builder/conditions_spec.rb
deleted file mode 100644
index dc2d10a2f6..0000000000
--- a/spec/active_relation/sql_builder/conditions_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ConditionsBuilder do
- describe '#to_s' do
- describe 'with aliased columns' do
- it 'manufactures correct sql' do
- ConditionsBuilder.new do
- equals do
- column(:a, :b)
- column(:c, :d, 'e')
- end
- end.to_s.should be_like("""
- `a`.`b` = `c`.`d`
- """)
- end
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/sql_builder/delete_builder_spec.rb b/spec/active_relation/sql_builder/delete_builder_spec.rb
deleted file mode 100644
index fd62fde155..0000000000
--- a/spec/active_relation/sql_builder/delete_builder_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe DeleteBuilder do
- describe '#to_s' do
- it 'manufactures correct sql' do
- DeleteBuilder.new do
- delete
- from :users
- where do
- equals do
- column :users, :id
- value 1
- end
- end
- end.to_s.should be_like("""
- DELETE
- FROM `users`
- WHERE `users`.`id` = 1
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/sql_builder/insert_builder_spec.rb b/spec/active_relation/sql_builder/insert_builder_spec.rb
deleted file mode 100644
index dddc971986..0000000000
--- a/spec/active_relation/sql_builder/insert_builder_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe InsertBuilder do
- describe '#to_s' do
- it 'manufactures correct sql' do
- InsertBuilder.new do
- insert
- into :users
- columns do
- column :users, :id
- column :users, :name
- end
- values do
- row 1, 'bob'
- row 2, 'moe'
- end
- end.to_s.should be_like("""
- INSERT
- INTO `users`
- (`users`.`id`, `users`.`name`) VALUES (1, 'bob'), (2, 'moe')
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/sql_builder/select_builder_spec.rb b/spec/active_relation/sql_builder/select_builder_spec.rb
deleted file mode 100644
index 6539afe0c4..0000000000
--- a/spec/active_relation/sql_builder/select_builder_spec.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe SelectBuilder do
- describe '#to_s' do
- describe 'with select and from clauses' do
- it 'manufactures correct sql' do
- SelectBuilder.new do
- select do
- all
- end
- from :users
- end.to_s.should be_like("""
- SELECT *
- FROM `users`
- """)
- end
- end
-
- describe 'with specified columns and column aliases' do
- it 'manufactures correct sql' do
- SelectBuilder.new do
- select do
- column :a, :b, 'c'
- column :e, :f
- end
- from :users
- end.to_s.should be_like("""
- SELECT `a`.`b` AS 'c', `e`.`f`
- FROM `users`
- """)
- end
- end
-
- describe 'with where clause' do
- it 'manufactures correct sql' do
- SelectBuilder.new do
- select do
- all
- end
- from :users
- where do
- equals do
- value 1
- column :b, :c
- end
- end
- end.to_s.should be_like("""
- SELECT *
- FROM `users`
- WHERE 1 = `b`.`c`
- """)
- end
-
- it 'accepts arbitrary strings' do
- SelectBuilder.new do
- select do
- all
- end
- from :users
- where do
- value "'a' = 'a'"
- end
- end.to_s.should be_like("""
- SELECT *
- FROM `users`
- WHERE 'a' = 'a'
- """)
- end
- end
-
- describe 'with inner join' do
- it 'manufactures correct sql' do
- SelectBuilder.new do
- select do
- all
- end
- from :users do
- inner_join(:friendships) do
- equals do
- column :users, :id
- column :friendships, :user_id
- end
- end
- end
- end.to_s.should be_like("""
- SELECT *
- FROM `users`
- INNER JOIN `friendships`
- ON `users`.`id` = `friendships`.`user_id`
- """)
- end
-
- it 'accepts arbitrary on strings' do
- SelectBuilder.new do
- select do
- all
- end
- from :users do
- inner_join :friendships do
- value "arbitrary"
- end
- end
- end.to_s.should be_like("""
- SELECT *
- FROM `users`
- INNER JOIN `friendships` ON arbitrary
- """)
- end
- end
-
- describe 'with order' do
- it 'manufactures correct sql' do
- SelectBuilder.new do
- select do
- all
- end
- from :users
- order_by do
- column :users, :id
- column :users, :created_at, 'alias'
- end
- end.to_s.should be_like("""
- SELECT *
- FROM `users`
- ORDER BY `users`.`id`, `users`.`created_at`
- """)
- end
- end
-
- describe 'with limit and/or offset' do
- it 'manufactures correct sql' do
- SelectBuilder.new do
- select do
- all
- end
- from :users
- limit 10
- offset 10
- end.to_s.should be_like("""
- SELECT *
- FROM `users`
- LIMIT 10
- OFFSET 10
- """)
- end
- end
- end
-end \ No newline at end of file