From 09a5847044e63bcc2b391720cf6bf084f03b4501 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 6 Aug 2010 10:06:19 -0700 Subject: removing test code from implementation --- .../memory/integration/joins/cross_engine_spec.rb | 26 +++++++++++++++------- spec/engines/memory/unit/relations/array_spec.rb | 11 ++++----- spec/engines/memory/unit/relations/join_spec.rb | 11 ++++----- spec/engines/memory/unit/relations/order_spec.rb | 11 ++++----- spec/engines/memory/unit/relations/project_spec.rb | 10 ++++----- spec/engines/memory/unit/relations/skip_spec.rb | 13 +++++++---- spec/engines/memory/unit/relations/take_spec.rb | 10 +++++---- spec/engines/memory/unit/relations/where_spec.rb | 18 +++++++++------ 8 files changed, 67 insertions(+), 43 deletions(-) (limited to 'spec/engines') diff --git a/spec/engines/memory/integration/joins/cross_engine_spec.rb b/spec/engines/memory/integration/joins/cross_engine_spec.rb index 091fd2ceda..4646eeba2f 100644 --- a/spec/engines/memory/integration/joins/cross_engine_spec.rb +++ b/spec/engines/memory/integration/joins/cross_engine_spec.rb @@ -25,10 +25,15 @@ module Arel .on(@users[:id].eq(@photos[:user_id])) \ .project(@users[:name], @photos[:camera_id]) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, ['bryan', @adapter_returns_integer ? 6 : '6']), - Row.new(relation, ['emilio', @adapter_returns_integer ? 42 : '42']) - ] + rows = relation.call + rows.length.should == 2 + [ + ['bryan', @adapter_returns_integer ? 6 : '6'], + ['emilio', @adapter_returns_integer ? 42 : '42'] + ].zip(rows).each do |tuple, row| + row.relation.should == relation + row.tuple.should == tuple + end end end end @@ -40,10 +45,15 @@ module Arel .on(@users[:id].eq(@photos[:user_id])) \ .project(@users[:name], @photos[:camera_id]) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, ['bryan', @adapter_returns_integer ? 6 : '6']), - Row.new(relation, ['emilio', @adapter_returns_integer ? 42 : '42']) - ] + rows = relation.call + rows.length.should == 2 + [ + ['bryan', @adapter_returns_integer ? 6 : '6'], + ['emilio', @adapter_returns_integer ? 42 : '42'] + ].zip(rows).each do |tuple, row| + row.relation.should == relation + row.tuple.should == tuple + end end end end diff --git a/spec/engines/memory/unit/relations/array_spec.rb b/spec/engines/memory/unit/relations/array_spec.rb index dcec2afa19..65bfb4025f 100644 --- a/spec/engines/memory/unit/relations/array_spec.rb +++ b/spec/engines/memory/unit/relations/array_spec.rb @@ -21,11 +21,12 @@ module Arel describe '#call' do it "manufactures an array of hashes of attributes to values" do - @relation.call.should == [ - Row.new(@relation, [1, 'duck']), - Row.new(@relation, [2, 'duck']), - Row.new(@relation, [3, 'goose']) - ] + rows = @relation.call + rows.length.should == 3 + @relation.array.zip(rows).each do |tuple, row| + row.relation.should == @relation + row.tuple.should == tuple + end end end end diff --git a/spec/engines/memory/unit/relations/join_spec.rb b/spec/engines/memory/unit/relations/join_spec.rb index 9a475d817d..93379985cb 100644 --- a/spec/engines/memory/unit/relations/join_spec.rb +++ b/spec/engines/memory/unit/relations/join_spec.rb @@ -18,11 +18,12 @@ module Arel .join(@relation2) \ .on(@relation1[:id].eq(@relation2[:id])) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, [1, 'duck', 1, 'duck' ]), - Row.new(relation, [2, 'duck', 2, 'duck' ]), - Row.new(relation, [3, 'goose', 3, 'goose']) - ] + rows = relation.call + rows.length.should == 3 + @relation1.array.zip(rows).each do |tuple, row| + row.relation.should == relation + row.tuple.should == (tuple * 2) + end end end end diff --git a/spec/engines/memory/unit/relations/order_spec.rb b/spec/engines/memory/unit/relations/order_spec.rb index 0d746bcd0a..86c59ffc46 100644 --- a/spec/engines/memory/unit/relations/order_spec.rb +++ b/spec/engines/memory/unit/relations/order_spec.rb @@ -15,11 +15,12 @@ module Arel @relation \ .order(@relation[:id].desc) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, [3, 'goose']), - Row.new(relation, [2, 'duck' ]), - Row.new(relation, [1, 'duck' ]) - ] + rows = relation.call + rows.length.should == 3 + @relation.array.reverse.zip(rows) do |tuple, row| + row.relation.should == relation + row.tuple.should == tuple + end end end end diff --git a/spec/engines/memory/unit/relations/project_spec.rb b/spec/engines/memory/unit/relations/project_spec.rb index 3970a50129..cf20573fd2 100644 --- a/spec/engines/memory/unit/relations/project_spec.rb +++ b/spec/engines/memory/unit/relations/project_spec.rb @@ -15,11 +15,11 @@ module Arel @relation \ .project(@relation[:id]) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, [1]), - Row.new(relation, [2]), - Row.new(relation, [3]) - ] + rows = relation.call + @relation.array.zip(rows) do |tuple, row| + row.relation.should == relation + row.tuple.should == [tuple.first] + end end end end diff --git a/spec/engines/memory/unit/relations/skip_spec.rb b/spec/engines/memory/unit/relations/skip_spec.rb index 4cf6c020bc..abb87d2e38 100644 --- a/spec/engines/memory/unit/relations/skip_spec.rb +++ b/spec/engines/memory/unit/relations/skip_spec.rb @@ -15,10 +15,15 @@ module Arel @relation \ .skip(1) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, [2, 'duck']), - Row.new(relation, [3, 'goose']), - ] + rows = relation.call + rows.length.should == 2 + one, two = *rows + + one.relation.should == relation + one.tuple.should == [2, 'duck'] + + two.relation.should == relation + two.tuple.should == [3, 'goose'] end end end diff --git a/spec/engines/memory/unit/relations/take_spec.rb b/spec/engines/memory/unit/relations/take_spec.rb index f74f1a74c8..b7e49ddca6 100644 --- a/spec/engines/memory/unit/relations/take_spec.rb +++ b/spec/engines/memory/unit/relations/take_spec.rb @@ -15,10 +15,12 @@ module Arel @relation \ .take(2) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, [1, 'duck']), - Row.new(relation, [2, 'duck']), - ] + rows = relation.call + rows.length.should == 2 + rows.each_with_index do |row, i| + row.relation.should == relation + row.tuple.should == [i + 1, 'duck'] + end end end end diff --git a/spec/engines/memory/unit/relations/where_spec.rb b/spec/engines/memory/unit/relations/where_spec.rb index 23aef5766e..c75fe10f1b 100644 --- a/spec/engines/memory/unit/relations/where_spec.rb +++ b/spec/engines/memory/unit/relations/where_spec.rb @@ -15,10 +15,12 @@ module Arel @relation \ .where(@relation[:id].lt(3)) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, [1, 'duck']), - Row.new(relation, [2, 'duck']), - ] + rows = relation.call + rows.length.should == 2 + rows.each_with_index do |row, i| + row.relation.should == relation + row.tuple.should == [i + 1, 'duck'] + end end end @@ -28,9 +30,11 @@ module Arel .where(@relation[:id].gt(1)) \ .where(@relation[:id].lt(3)) \ .tap do |relation| - relation.call.should == [ - Row.new(relation, [2, 'duck']) - ] + rows = relation.call + rows.length.should == 1 + row = rows.first + row.relation.should == relation + row.tuple.should == [2, 'duck'] end end end -- cgit v1.2.3