aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/nodes/select_core_spec.rb
blob: 30927abea6d13d7f29f2038e30dbb396537870de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
      check dolly.froms.should == %w[a0 b1 c2]
      check dolly.projections.should == %w[d0 e1 f2]
      check dolly.wheres.should == %w[g0 h1 i2]
    end
  end
end