Sha256: f1169e2ff74f3792bb306e8d055fdd9b298459e8be906779fc1db9b8fa069267

Contents?: true

Size: 926 Bytes

Versions: 16

Compression:

Stored size: 926 Bytes

Contents

require "spec_helper"

describe Ranking do

  context "with many items" do

    specify "it should give top x items" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      ranking[:c] = 1
      ranking.top(2).should == [:b,:a]
    end

    specify "if gives all items if param is not numeric" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      ranking[:c] = 1
      ranking.top(nil).should == [:b,:a, :c]
      ranking.top(:all).should == [:b,:a, :c]
    end

    specify "lowest item is at 0 percentile" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      ranking.percentile(:a).should == 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
      ranking.percentile(:b).should == 0.75
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
metric_fu-4.4.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.3.1 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.3.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.2.1 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.2.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.1.3 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.1.2 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.1.1 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.1.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.0.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-3.0.1 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-3.0.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-2.1.4.pre5 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-2.1.4.pre4 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-2.1.4.pre2 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-2.1.4.pre spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb