Sha256: 7040d82362763332fec9804eb68534de896b15f6f3fcbd7a0e9cdf2dd0dd3111

Contents?: true

Size: 696 Bytes

Versions: 31

Compression:

Stored size: 696 Bytes

Contents

require 'spec_helper'

describe Picky::Generators::Weights::Logarithmic do

  before(:each) do
    @cacher = described_class.new
  end

  describe 'generate_from' do
    it 'should not fail on empties' do
      @cacher.generate_from({ :key => [] }).should == { :key => 0 }
    end
    it 'should round to 2' do
      @cacher.generate_from({ :key => [1,2,3,4] }).should == { :key => 1.39 }
    end
  end

  describe 'weight_for' do
    it 'should be 0 for 0' do
      @cacher.weight_for(0).should == 0
    end
    it 'should be 0 for 1' do
      @cacher.weight_for(1).should == 0
    end
    it 'should be log(x) for x' do
      @cacher.weight_for(1234).should == Math.log(1234)
    end
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
picky-3.5.0 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.4.3 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.4.2 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.4.1 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.4.0 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.3.3 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.3.2 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.3.1 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.3.0 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.2.0 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.13 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.12 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.11 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.10 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.9 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.8 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.7 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.6 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.5 spec/lib/generators/weights/logarithmic_spec.rb
picky-3.1.4 spec/lib/generators/weights/logarithmic_spec.rb