aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'spec/arel/nodes')
-rw-r--r--spec/arel/nodes/delete_statement_spec.rb17
-rw-r--r--spec/arel/nodes/insert_statement_spec.rb22
-rw-r--r--spec/arel/nodes/select_core_spec.rb23
-rw-r--r--spec/arel/nodes/select_statement_spec.rb16
-rw-r--r--spec/arel/nodes/update_statement_spec.rb22
5 files changed, 100 insertions, 0 deletions
diff --git a/spec/arel/nodes/delete_statement_spec.rb b/spec/arel/nodes/delete_statement_spec.rb
new file mode 100644
index 0000000000..dd43b70d35
--- /dev/null
+++ b/spec/arel/nodes/delete_statement_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe Arel::Nodes::SelectStatement do
+ describe "#clone" do
+ it "clones where" do
+ statement = Arel::Nodes::DeleteStatement.new
+ statement.wheres = %w[a b c]
+
+ statement.wheres.each_with_index do |o, j|
+ o.should_receive(:clone).and_return("#{o}#{j}")
+ end
+
+ dolly = statement.clone
+ dolly.wheres.should == %w[a0 b1 c2]
+ end
+ end
+end
diff --git a/spec/arel/nodes/insert_statement_spec.rb b/spec/arel/nodes/insert_statement_spec.rb
new file mode 100644
index 0000000000..644e3fb192
--- /dev/null
+++ b/spec/arel/nodes/insert_statement_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe Arel::Nodes::InsertStatement do
+ describe "#clone" do
+ it "clones columns and values" do
+ statement = Arel::Nodes::InsertStatement.new
+ statement.columns = %w[a b c]
+ statement.values = %w[x y z]
+
+ statement.columns.each_with_index do |o, j|
+ o.should_receive(:clone).and_return("#{o}#{j}")
+ end
+ statement.values.each_with_index do |o, j|
+ o.should_receive(:clone).and_return("#{o}#{j}")
+ end
+
+ dolly = statement.clone
+ dolly.columns.should == %w[a0 b1 c2]
+ dolly.values.should == %w[x0 y1 z2]
+ end
+ end
+end
diff --git a/spec/arel/nodes/select_core_spec.rb b/spec/arel/nodes/select_core_spec.rb
new file mode 100644
index 0000000000..cf717a3904
--- /dev/null
+++ b/spec/arel/nodes/select_core_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe Arel::Nodes::SelectCore do
+ describe "#clone" do
+ it "clones froms, projections and wheres" do
+ core = Arel::Nodes::SelectCore.new
+ core.instance_variable_set "@froms", %w[a b c]
+ core.instance_variable_set "@projections", %w[d e f]
+ core.instance_variable_set "@wheres", %w[g h i]
+
+ [:froms, :projections, :wheres].each do |array_attr|
+ core.send(array_attr).each_with_index do |o, j|
+ o.should_receive(:clone).and_return("#{o}#{j}")
+ end
+ end
+
+ dolly = core.clone
+ dolly.froms.should == %w[a0 b1 c2]
+ dolly.projections.should == %w[d0 e1 f2]
+ dolly.wheres.should == %w[g0 h1 i2]
+ end
+ end
+end
diff --git a/spec/arel/nodes/select_statement_spec.rb b/spec/arel/nodes/select_statement_spec.rb
new file mode 100644
index 0000000000..a024710c78
--- /dev/null
+++ b/spec/arel/nodes/select_statement_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe Arel::Nodes::SelectStatement do
+ describe "#clone" do
+ it "clones cores" do
+ statement = Arel::Nodes::SelectStatement.new %w[a b c]
+
+ statement.cores.each_with_index do |o, j|
+ o.should_receive(:clone).and_return("#{o}#{j}")
+ end
+
+ dolly = statement.clone
+ dolly.cores.should == %w[a0 b1 c2]
+ end
+ end
+end
diff --git a/spec/arel/nodes/update_statement_spec.rb b/spec/arel/nodes/update_statement_spec.rb
new file mode 100644
index 0000000000..8cbca1fd73
--- /dev/null
+++ b/spec/arel/nodes/update_statement_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe Arel::Nodes::UpdateStatement do
+ describe "#clone" do
+ it "clones wheres and values" do
+ statement = Arel::Nodes::UpdateStatement.new
+ statement.wheres = %w[a b c]
+ statement.values = %w[x y z]
+
+ statement.wheres.each_with_index do |o, j|
+ o.should_receive(:clone).and_return("#{o}#{j}")
+ end
+ statement.values.each_with_index do |o, j|
+ o.should_receive(:clone).and_return("#{o}#{j}")
+ end
+
+ dolly = statement.clone
+ dolly.wheres.should == %w[a0 b1 c2]
+ dolly.values.should == %w[x0 y1 z2]
+ end
+ end
+end