Sha256: 9ea46169f38642e05ab91aebcbd890b3996c9040d551082cbbae1aa51a38c1cb

Contents?: true

Size: 819 Bytes

Versions: 7

Compression:

Stored size: 819 Bytes

Contents

require 'guerrilla_patch/aggregate_by_type/divide_by_type'

describe DivideByType do
  before(:each) do
    @ratios = { '1A' => 50, '1B' => 30, '1C' => 20 }
  end

  it 'knows ratios' do
    DivideByType.divide(@ratios, 50).should ==
      {'1A' => 25, '1B' => 15, '1C' => 10}
  end

  it 'knows ratios for negative values' do
    DivideByType.divide(@ratios, -50).should ==
      {'1A' => -25, '1B' => -15, '1C' => -10}
  end

  it 'returns empty dividis for zero' do
    DivideByType.divide(@ratios, 0).should == {}
  end

  it 'knows how to divide without ratios' do
    DivideByType.divide({}, 10).should == { :no_division => 10}
  end

  it 'knows how to divide negative ratios' do
     DivideByType.divide({"E2112"=>279.37, "E2111"=>-233.06}, 46.31).should == { "E2112" => 279.37, "E2111" => -233.06 }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
guerrilla_patch-3.0.3 spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
guerrilla_patch-3.0.2 spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
guerrilla_patch-2.8.7 spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
guerrilla_patch-2.8.6 spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
guerrilla_patch-2.8.5 spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
guerrilla_patch-2.8.4 spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
guerrilla_patch-2.8.3 spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb