aboutsummaryrefslogtreecommitdiffstats
path: root/spec/relations/join_operation_spec.rb
blob: 13e50e057e0a828e7955b25e79c08ab5f626d890 (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
24
25
26
27
28
29
require File.join(File.dirname(__FILE__), '..', 'spec_helper')

describe JoinOperation, 'between two relations' do
  before do
    @relation1 = TableRelation.new(:foo)
    @relation2 = TableRelation.new(:bar)
  end
  
  describe JoinOperation, '==' do
    it "obtains if the relations of both joins are identical" do
      JoinOperation.new(@relation1, @relation2).should == JoinOperation.new(@relation1, @relation2)
      JoinOperation.new(@relation1, @relation2).should_not == JoinOperation.new(@relation1, @relation1)
    end
  
    it "is commutative on the relations" do
      JoinOperation.new(@relation1, @relation2).should == JoinOperation.new(@relation2, @relation1)
    end
  end

  describe JoinOperation, 'on' do
    before do
      @predicate = Predicate.new
    end
    
    it "manufactures a JoinRelation" do
      JoinOperation.new(@relation1, @relation2).on(@predicate).should == JoinRelation.new(@relation1, @relation2, @predicate)
    end
  end
end