diff options
author | Mike Dalessio <mike@csa.net> | 2010-08-19 01:30:36 -0400 |
---|---|---|
committer | Mike Dalessio <mike@csa.net> | 2010-08-19 01:38:09 -0400 |
commit | 6b056ef108526de90f9537e2a5f663a9a2b33409 (patch) | |
tree | 2ba5fde9c06e35e31f5d315bcf3560f6f4d36498 /spec/arel/nodes/select_core_spec.rb | |
parent | 02ab2b37d7fdd823cf3aaac66052437dde36daa3 (diff) | |
download | rails-6b056ef108526de90f9537e2a5f663a9a2b33409.tar.gz rails-6b056ef108526de90f9537e2a5f663a9a2b33409.tar.bz2 rails-6b056ef108526de90f9537e2a5f663a9a2b33409.zip |
SelectCore deep copies attributes
Diffstat (limited to 'spec/arel/nodes/select_core_spec.rb')
-rw-r--r-- | spec/arel/nodes/select_core_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
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 |