Skip to content

Commit

Permalink
Added specs to ensure Unioned Collections work with aggregate functions
Browse files Browse the repository at this point in the history
* This corresponds with fixes made in dm-core that allow these specs
  to pass.

[#1121 state:resolved]
  • Loading branch information
dkubb committed Nov 11, 2009
1 parent 688e717 commit 9dea5af
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions dm-aggregates/spec/public/collection_spec.rb
Expand Up @@ -54,5 +54,53 @@
end
end
end

describe 'with collections created with Set operations' do
before do
@collection = @dragons.all(:name => 'George') | @dragons.all(:name => 'Puff')
end

describe '#size' do
subject { @collection.size }

it { should == 2 }
end

describe '#count' do
subject { @collection.count }

it { should == 2 }
end

describe '#min' do
subject { @collection.min(:toes_on_claw) }

it { should == 3 }
end

describe '#max' do
subject { @collection.max(:toes_on_claw) }

it { should == 4 }
end

describe '#avg' do
subject { @collection.avg(:toes_on_claw) }

it { should == 3.5 }
end

describe '#sum' do
subject { @collection.sum(:toes_on_claw) }

it { should == 7 }
end

describe '#aggregate' do
subject { @collection.aggregate(:all.count, :name.count, :toes_on_claw.min, :toes_on_claw.max, :toes_on_claw.avg, :toes_on_claw.sum)}

it { should == [ 2, 2, 3, 4, 3.5, 7 ] }
end
end
end
end

0 comments on commit 9dea5af

Please sign in to comment.