From 2fe585328d6a24df310d3e60059c9c7b05b64bac Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Tue, 27 May 2008 14:19:59 -0700 Subject: performing in memory joins --- .../engines/memory/unit/relations/join_spec.rb | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 spec/arel/engines/memory/unit/relations/join_spec.rb (limited to 'spec') diff --git a/spec/arel/engines/memory/unit/relations/join_spec.rb b/spec/arel/engines/memory/unit/relations/join_spec.rb new file mode 100644 index 0000000000..920cc55d0a --- /dev/null +++ b/spec/arel/engines/memory/unit/relations/join_spec.rb @@ -0,0 +1,32 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'spec_helper') + +module Arel + describe Join do + before do + @relation1 = Array.new([ + [1, 'duck' ], + [2, 'duck' ], + [3, 'goose'] + ], [:id, :name]) + @relation2 = @relation1.alias + @relation3 = @relation1.alias + end + + describe InnerJoin do + describe '#call' do + it 'combines the two tables where the predicate obtains' do + @relation1 \ + .join(@relation2) \ + .on(@relation1[:id].eq(@relation2[:id])) \ + .let 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']) + ] + end + end + end + end + end +end \ No newline at end of file -- cgit v1.2.3