Sha256: 864efb528f8bd9a394a00bd31cd0fc0c714ae0151f27f8a6ba76ce00687151ff

Contents?: true

Size: 731 Bytes

Versions: 12

Compression:

Stored size: 731 Bytes

Contents

require "spec_helper"
MetricFu.metrics_require { 'hotspots/analysis/ranking' }

describe MetricFu::Ranking do

  context "with many items" do

    specify "#top" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      ranking[:c] = 1
      expect(ranking.top).to eq([:b,:a, :c])
    end

    specify "lowest item is at 0 percentile" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      expect(ranking.percentile(:a)).to eq(0)
    end

    specify "highest item is at high percentile" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      ranking[:c] = 0
      ranking[:d] = 5
      expect(ranking.percentile(:b)).to eq(0.75)
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
metric_fu-4.11.3 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.11.2 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.11.1 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.11.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.10.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.9.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.8.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.7.4 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.7.3 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.7.2 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.7.1 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.7.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb