require 'spec_helper' describe Mongoid::Report do describe '.summary' do let(:klass) { Model } let(:yesterday) { Date.parse("19-12-2004") } let(:today) { Date.parse("20-12-2004") } it 'returns summary for all rows' do klass.create!(day: today , field1: 1) klass.create!(day: today , field1: 1) klass.create!(day: yesterday , field1: 1) example = Report3.new rows = example.aggregate_for(klass) rows = rows.all expect(rows.count).to eq(2) expect(rows.summary[:field1]).to eq(3) expect(rows.summary['field1']).to eq(3) end end end