Sha256: 52f5d6517d7eeb443a2417aa8e0976fba7ff6eb4d0db90d3285e10bdeb95464c
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require 'spec_helper' module Prosperity describe Aggregate::AggregateBuilder do describe "#build" do context "the count aggregate" do subject do described_class.new do count end.build end it "returns a Aggregate::Count" do expect(subject).to be_an(Aggregate::Count) end end AGGREGATES = { :sum => Aggregate::Sum, :minimum => Aggregate::Minimum, :maximum => Aggregate::Maximum, :average => Aggregate::Average, } AGGREGATES.each do |func, type| context "the #{func} aggregate" do subject do described_class.new do send(func, :some_column) end.build end it "returns a #{type}" do expect(subject).to be_an(type) expect(subject.column).to eq(:some_column) end end end end context "a sql aggregate from a block" do subject do described_class.new do "SUM(value)" end.build end it "returns a SQL type" do expect(subject).to be_an(Aggregate::Sql) expect(subject.to_sql).to eq('SUM(value)') end end context "a sql aggregate from a block" do subject do described_class.new("SUM(value)").build end it "returns a SQL type" do expect(subject).to be_an(Aggregate::Sql) expect(subject.to_sql).to eq('SUM(value)') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prosperity-0.0.11 | spec/lib/prosperity/aggregate/aggregate_builder_spec.rb |
prosperity-0.0.10 | spec/lib/prosperity/aggregate/aggregate_builder_spec.rb |