diff options
author | Mike Dalessio <mike@csa.net> | 2010-08-16 23:59:18 -0400 |
---|---|---|
committer | Mike Dalessio <mike@csa.net> | 2010-08-19 01:37:18 -0400 |
commit | 02ab2b37d7fdd823cf3aaac66052437dde36daa3 (patch) | |
tree | a9a1d16dd070ef00ee2aba04e613f3ebb838832a /spec/arel | |
parent | 788f33fb59af40e8cb29a233a8d6be9941b52ea7 (diff) | |
download | rails-02ab2b37d7fdd823cf3aaac66052437dde36daa3.tar.gz rails-02ab2b37d7fdd823cf3aaac66052437dde36daa3.tar.bz2 rails-02ab2b37d7fdd823cf3aaac66052437dde36daa3.zip |
Statement nodes deep-copy AST nodes
Diffstat (limited to 'spec/arel')
-rw-r--r-- | spec/arel/nodes/insert_statement_spec.rb | 22 | ||||
-rw-r--r-- | spec/arel/nodes/select_statement_spec.rb | 16 | ||||
-rw-r--r-- | spec/arel/nodes/update_statement_spec.rb | 22 |
3 files changed, 60 insertions, 0 deletions
diff --git a/spec/arel/nodes/insert_statement_spec.rb b/spec/arel/nodes/insert_statement_spec.rb new file mode 100644 index 0000000000..d8b02b6703 --- /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 cores" 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_statement_spec.rb b/spec/arel/nodes/select_statement_spec.rb new file mode 100644 index 0000000000..04b850823c --- /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..438eaf1dc2 --- /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 cores" 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 |