Sha256: ec2d3f7ea0ca921383ac4aac637c730f12395767573923e50b45b51a3ed7bab7

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

require 'spec_helper'

describe 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

2 entries across 2 versions & 1 rubygems

Version Path
picky-2.7.0 spec/lib/generators/weights/logarithmic_spec.rb
picky-2.6.0 spec/lib/generators/weights/logarithmic_spec.rb