From 518db17ca3dade07fc67b6044b63c826cefb1442 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 19 May 2008 13:57:21 -0700 Subject: renamed ion classes --- spec/arel/unit/relations/delete_spec.rb | 42 ++++++++++++++++ spec/arel/unit/relations/deletion_spec.rb | 42 ---------------- spec/arel/unit/relations/group_spec.rb | 32 +++++++++++++ spec/arel/unit/relations/grouping_spec.rb | 32 ------------- spec/arel/unit/relations/insert_spec.rb | 71 +++++++++++++++++++++++++++ spec/arel/unit/relations/insertion_spec.rb | 71 --------------------------- spec/arel/unit/relations/project_spec.rb | 74 +++++++++++++++++++++++++++++ spec/arel/unit/relations/projection_spec.rb | 74 ----------------------------- spec/arel/unit/relations/relation_spec.rb | 6 +-- spec/arel/unit/session/session_spec.rb | 2 +- 10 files changed, 223 insertions(+), 223 deletions(-) create mode 100644 spec/arel/unit/relations/delete_spec.rb delete mode 100644 spec/arel/unit/relations/deletion_spec.rb create mode 100644 spec/arel/unit/relations/group_spec.rb delete mode 100644 spec/arel/unit/relations/grouping_spec.rb create mode 100644 spec/arel/unit/relations/insert_spec.rb delete mode 100644 spec/arel/unit/relations/insertion_spec.rb create mode 100644 spec/arel/unit/relations/project_spec.rb delete mode 100644 spec/arel/unit/relations/projection_spec.rb (limited to 'spec') diff --git a/spec/arel/unit/relations/delete_spec.rb b/spec/arel/unit/relations/delete_spec.rb new file mode 100644 index 0000000000..46c2ec9143 --- /dev/null +++ b/spec/arel/unit/relations/delete_spec.rb @@ -0,0 +1,42 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module Arel + describe Deletion do + before do + @relation = Table.new(:users) + end + + describe '#to_sql' do + it 'manufactures sql deleting a table relation' do + Deletion.new(@relation).to_sql.should be_like(" + DELETE + FROM `users` + ") + end + + it 'manufactures sql deleting a where relation' do + Deletion.new(@relation.where(@relation[:id].eq(1))).to_sql.should be_like(" + DELETE + FROM `users` + WHERE `users`.`id` = 1 + ") + end + + it "manufactures sql deleting a ranged relation" do + Deletion.new(@relation.take(1)).to_sql.should be_like(" + DELETE + FROM `users` + LIMIT 1 + ") + end + end + + describe '#call' do + it 'executes a delete on the connection' do + deletion = Deletion.new(@relation) + mock(connection = Object.new).delete(deletion.to_sql) + deletion.call(connection) + end + end + end +end \ No newline at end of file diff --git a/spec/arel/unit/relations/deletion_spec.rb b/spec/arel/unit/relations/deletion_spec.rb deleted file mode 100644 index 46c2ec9143..0000000000 --- a/spec/arel/unit/relations/deletion_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') - -module Arel - describe Deletion do - before do - @relation = Table.new(:users) - end - - describe '#to_sql' do - it 'manufactures sql deleting a table relation' do - Deletion.new(@relation).to_sql.should be_like(" - DELETE - FROM `users` - ") - end - - it 'manufactures sql deleting a where relation' do - Deletion.new(@relation.where(@relation[:id].eq(1))).to_sql.should be_like(" - DELETE - FROM `users` - WHERE `users`.`id` = 1 - ") - end - - it "manufactures sql deleting a ranged relation" do - Deletion.new(@relation.take(1)).to_sql.should be_like(" - DELETE - FROM `users` - LIMIT 1 - ") - end - end - - describe '#call' do - it 'executes a delete on the connection' do - deletion = Deletion.new(@relation) - mock(connection = Object.new).delete(deletion.to_sql) - deletion.call(connection) - end - end - end -end \ No newline at end of file diff --git a/spec/arel/unit/relations/group_spec.rb b/spec/arel/unit/relations/group_spec.rb new file mode 100644 index 0000000000..a0147b9416 --- /dev/null +++ b/spec/arel/unit/relations/group_spec.rb @@ -0,0 +1,32 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module Arel + describe Group do + before do + @relation = Table.new(:users) + @attribute = @relation[:id] + end + + describe '#to_sql' do + describe 'when given a predicate' do + it "manufactures sql with where clause conditions" do + Group.new(@relation, @attribute).to_sql.should be_like(" + SELECT `users`.`id`, `users`.`name` + FROM `users` + GROUP BY `users`.`id` + ") + end + end + + describe 'when given a string' do + it "passes the string through to the where clause" do + Group.new(@relation, 'asdf').to_sql.should be_like(" + SELECT `users`.`id`, `users`.`name` + FROM `users` + GROUP BY asdf + ") + end + end + end + end +end \ No newline at end of file diff --git a/spec/arel/unit/relations/grouping_spec.rb b/spec/arel/unit/relations/grouping_spec.rb deleted file mode 100644 index 5f781727cf..0000000000 --- a/spec/arel/unit/relations/grouping_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') - -module Arel - describe Grouping do - before do - @relation = Table.new(:users) - @attribute = @relation[:id] - end - - describe '#to_sql' do - describe 'when given a predicate' do - it "manufactures sql with where clause conditions" do - Grouping.new(@relation, @attribute).to_sql.should be_like(" - SELECT `users`.`id`, `users`.`name` - FROM `users` - GROUP BY `users`.`id` - ") - end - end - - describe 'when given a string' do - it "passes the string through to the where clause" do - Grouping.new(@relation, 'asdf').to_sql.should be_like(" - SELECT `users`.`id`, `users`.`name` - FROM `users` - GROUP BY asdf - ") - end - end - end - end -end \ No newline at end of file diff --git a/spec/arel/unit/relations/insert_spec.rb b/spec/arel/unit/relations/insert_spec.rb new file mode 100644 index 0000000000..b983e545a4 --- /dev/null +++ b/spec/arel/unit/relations/insert_spec.rb @@ -0,0 +1,71 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module Arel + describe Insert do + before do + @relation = Table.new(:users) + end + + describe '#to_sql' do + it 'manufactures sql inserting data when given multiple rows' do + pending 'it should insert multiple rows' + @insertion = Insert.new(@relation, [@relation[:name] => "nick", @relation[:name] => "bryan"]) + + @insertion.to_sql.should be_like(" + INSERT + INTO `users` + (`users`.`name`) VALUES ('nick'), ('bryan') + ") + end + + it 'manufactures sql inserting data when given multiple values' do + @insertion = Insert.new(@relation, @relation[:id] => "1", @relation[:name] => "nick") + + @insertion.to_sql.should be_like(" + INSERT + INTO `users` + (`users`.`id`, `users`.`name`) VALUES (1, 'nick') + ") + end + + describe 'when given values whose types correspond to the types of the attributes' do + before do + @insertion = Insert.new(@relation, @relation[:name] => "nick") + end + + it 'manufactures sql inserting data' do + @insertion.to_sql.should be_like(" + INSERT + INTO `users` + (`users`.`name`) VALUES ('nick') + ") + end + end + + describe 'when given values whose types differ from from the types of the attributes' do + before do + @insertion = Insert.new(@relation, @relation[:id] => '1-asdf') + end + + it 'manufactures sql inserting data' do + @insertion.to_sql.should be_like(" + INSERT + INTO `users` + (`users`.`id`) VALUES (1) + ") + end + end + end + + describe '#call' do + before do + @insertion = Insert.new(@relation, @relation[:name] => "nick") + end + + it 'executes an insert on the connection' do + mock(connection = Object.new).insert(@insertion.to_sql) + @insertion.call(connection) + end + end + end +end \ No newline at end of file diff --git a/spec/arel/unit/relations/insertion_spec.rb b/spec/arel/unit/relations/insertion_spec.rb deleted file mode 100644 index 10b70a2036..0000000000 --- a/spec/arel/unit/relations/insertion_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') - -module Arel - describe Insertion do - before do - @relation = Table.new(:users) - end - - describe '#to_sql' do - it 'manufactures sql inserting data when given multiple rows' do - pending 'it should insert multiple rows' - @insertion = Insertion.new(@relation, [@relation[:name] => "nick", @relation[:name] => "bryan"]) - - @insertion.to_sql.should be_like(" - INSERT - INTO `users` - (`users`.`name`) VALUES ('nick'), ('bryan') - ") - end - - it 'manufactures sql inserting data when given multiple values' do - @insertion = Insertion.new(@relation, @relation[:id] => "1", @relation[:name] => "nick") - - @insertion.to_sql.should be_like(" - INSERT - INTO `users` - (`users`.`id`, `users`.`name`) VALUES (1, 'nick') - ") - end - - describe 'when given values whose types correspond to the types of the attributes' do - before do - @insertion = Insertion.new(@relation, @relation[:name] => "nick") - end - - it 'manufactures sql inserting data' do - @insertion.to_sql.should be_like(" - INSERT - INTO `users` - (`users`.`name`) VALUES ('nick') - ") - end - end - - describe 'when given values whose types differ from from the types of the attributes' do - before do - @insertion = Insertion.new(@relation, @relation[:id] => '1-asdf') - end - - it 'manufactures sql inserting data' do - @insertion.to_sql.should be_like(" - INSERT - INTO `users` - (`users`.`id`) VALUES (1) - ") - end - end - end - - describe '#call' do - before do - @insertion = Insertion.new(@relation, @relation[:name] => "nick") - end - - it 'executes an insert on the connection' do - mock(connection = Object.new).insert(@insertion.to_sql) - @insertion.call(connection) - end - end - end -end \ No newline at end of file diff --git a/spec/arel/unit/relations/project_spec.rb b/spec/arel/unit/relations/project_spec.rb new file mode 100644 index 0000000000..2a4b690dd8 --- /dev/null +++ b/spec/arel/unit/relations/project_spec.rb @@ -0,0 +1,74 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module Arel + describe Project do + before do + @relation = Table.new(:users) + @attribute = @relation[:id] + end + + describe '#attributes' do + before do + @projection = Project.new(@relation, @attribute) + end + + it "manufactures attributes associated with the projection relation" do + @projection.attributes.should == [@attribute].collect { |a| a.bind(@projection) } + end + end + + describe '#to_sql' do + describe 'when given an attribute' do + it "manufactures sql with a limited select clause" do + Project.new(@relation, @attribute).to_sql.should be_like(" + SELECT `users`.`id` + FROM `users` + ") + end + end + + describe 'when given a relation' do + before do + @scalar_relation = Project.new(@relation, @relation[:name]) + end + + it "manufactures sql with scalar selects" do + Project.new(@relation, @scalar_relation).to_sql.should be_like(" + SELECT (SELECT `users`.`name` FROM `users`) AS `users` FROM `users` + ") + end + end + + describe 'when given a string' do + it "passes the string through to the select clause" do + Project.new(@relation, 'asdf').to_sql.should be_like(" + SELECT asdf FROM `users` + ") + end + end + + describe 'when given an expression' do + it 'manufactures sql with expressions' do + @relation.project(@attribute.count).to_sql.should be_like(" + SELECT COUNT(`users`.`id`) + FROM `users` + ") + end + end + end + + describe '#aggregation?' do + describe 'when the projections are attributes' do + it 'returns false' do + Project.new(@relation, @attribute).should_not be_aggregation + end + end + + describe 'when the projections include an aggregation' do + it "obtains" do + Project.new(@relation, @attribute.sum).should be_aggregation + end + end + end + end +end \ No newline at end of file diff --git a/spec/arel/unit/relations/projection_spec.rb b/spec/arel/unit/relations/projection_spec.rb deleted file mode 100644 index 3c6a092db5..0000000000 --- a/spec/arel/unit/relations/projection_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') - -module Arel - describe Projection do - before do - @relation = Table.new(:users) - @attribute = @relation[:id] - end - - describe '#attributes' do - before do - @projection = Projection.new(@relation, @attribute) - end - - it "manufactures attributes associated with the projection relation" do - @projection.attributes.should == [@attribute].collect { |a| a.bind(@projection) } - end - end - - describe '#to_sql' do - describe 'when given an attribute' do - it "manufactures sql with a limited select clause" do - Projection.new(@relation, @attribute).to_sql.should be_like(" - SELECT `users`.`id` - FROM `users` - ") - end - end - - describe 'when given a relation' do - before do - @scalar_relation = Projection.new(@relation, @relation[:name]) - end - - it "manufactures sql with scalar selects" do - Projection.new(@relation, @scalar_relation).to_sql.should be_like(" - SELECT (SELECT `users`.`name` FROM `users`) AS `users` FROM `users` - ") - end - end - - describe 'when given a string' do - it "passes the string through to the select clause" do - Projection.new(@relation, 'asdf').to_sql.should be_like(" - SELECT asdf FROM `users` - ") - end - end - - describe 'when given an expression' do - it 'manufactures sql with expressions' do - @relation.project(@attribute.count).to_sql.should be_like(" - SELECT COUNT(`users`.`id`) - FROM `users` - ") - end - end - end - - describe '#aggregation?' do - describe 'when the projections are attributes' do - it 'returns false' do - Projection.new(@relation, @attribute).should_not be_aggregation - end - end - - describe 'when the projections include an aggregation' do - it "obtains" do - Projection.new(@relation, @attribute.sum).should be_aggregation - end - end - end - end -end \ No newline at end of file diff --git a/spec/arel/unit/relations/relation_spec.rb b/spec/arel/unit/relations/relation_spec.rb index 78e391640e..77a787b840 100644 --- a/spec/arel/unit/relations/relation_spec.rb +++ b/spec/arel/unit/relations/relation_spec.rb @@ -62,7 +62,7 @@ module Arel describe '#project' do it "manufactures a projection relation" do @relation.project(@attribute1, @attribute2). \ - should == Projection.new(@relation, @attribute1, @attribute2) + should == Project.new(@relation, @attribute1, @attribute2) end describe "when given blank attributes" do @@ -136,7 +136,7 @@ module Arel describe '#group' do it 'manufactures a group relation' do - @relation.group(@attribute1, @attribute2).should == Grouping.new(@relation, @attribute1, @attribute2) + @relation.group(@attribute1, @attribute2).should == Group.new(@relation, @attribute1, @attribute2) end describe 'when given blank groupings' do @@ -160,7 +160,7 @@ module Arel it 'manufactures an insertion relation' do Session.start do record = {@relation[:name] => 'carl'} - mock(Session.new).create(Insertion.new(@relation, record)) + mock(Session.new).create(Insert.new(@relation, record)) @relation.insert(record).should == @relation end end diff --git a/spec/arel/unit/session/session_spec.rb b/spec/arel/unit/session/session_spec.rb index fbb2b7791b..7582aa35e1 100644 --- a/spec/arel/unit/session/session_spec.rb +++ b/spec/arel/unit/session/session_spec.rb @@ -32,7 +32,7 @@ module Arel describe Session::CRUD do before do - @insert = Insertion.new(@relation, @relation[:name] => 'nick') + @insert = Insert.new(@relation, @relation[:name] => 'nick') @update = Update.new(@relation, @relation[:name] => 'nick') @delete = Deletion.new(@relation) @read = @relation -- cgit v1.2.3