Sha256: b8bc93cc60bb3c54ba12ce39110af885596b209bea98178f2b04027855530979
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
shared_examples "an extractor" do AGGREGATES = [:sum, :minimum, :maximum, :average] let(:expected_data_size) { 14 } ["sql", "normal"].each do |type| AGGREGATES.each do |agg| context "a #{type} metric with aggregate #{agg}" do let(:metric) do Class.new(Prosperity::Metric) do if type == 'sql' sql "SELECT * FROM users" else scope { User } end aggregate { send(agg, :value) } end.new end describe "#to_a" do let(:data) { subject.to_a } it "returns the one entry per period" do expect(data.size).to eq(expected_data_size) end end end end context "a sql metric with default aggregat" do let(:metric) do Class.new(Prosperity::Metric) do if type == 'sql' sql "SELECT * FROM users" else scope { User } end end.new end describe "#to_a" do let(:data) { subject.to_a } it "returns the one entry per period" do expect(data.size).to eq(expected_data_size) end end end end context "a full SQL metric" do let(:metric) do Class.new(Prosperity::Metric) do sql "SELECT * FROM users" group_by "created_at" aggregate { "SUM(value)" } end.new end describe "#to_a" do let(:data) { subject.to_a } it "returns the one entry per period" do expect(data.size).to eq(expected_data_size) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prosperity-0.0.10 | spec/support/shared/extractors.rb |