Sha256: 82cf8cca0092c20eb28286876eda4df188b84bf29556d01b411f0c27c5572caa

Contents?: true

Size: 1.54 KB

Versions: 35

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe Calculations::Location do
  
  context 'with precision 1' do
    before(:each) do
      @calculation = Calculations::Location.new 1.5, 1
      @calculation.minimum = 42.7
    end
    describe 'recalculate' do
      it 'sets the minimum close value to the minimum minus user grid' do
        @calculation.recalculate(41.2).should == 1
      end
      it 'sets the minimum value to 1 plus precision' do
        @calculation.recalculate(42.7).should == 2
      end
      it 'sets the minimum value plus 2/3 of the grid size to 2 plus 1 grid length' do
        @calculation.recalculate(43.7).should == 3
      end
      it 'sets the minimum value plus 20/3 of the grid size to 2 plus 10 grid length' do
        @calculation.recalculate(52.7).should == 12
      end
    end
  end
  
  context 'with precision 3' do
    before(:each) do
      @calculation = Calculations::Location.new 1.5, 3
      @calculation.minimum = 42.7
    end
    describe 'recalculate' do
      it 'sets the minimum close value to the minimum minus user grid' do
        @calculation.recalculate(41.2).should == 1
      end
      it 'sets the minimum value to 1 plus precision' do
        @calculation.recalculate(42.7).should == 4
      end
      it 'sets the minimum value plus 2/3 of the grid size plus 1 plus precision plus 1 grid length' do
        @calculation.recalculate(43.7).should == 6
      end
      it 'sets the minimum value plus 20/3 of the grid size to 2 plus 10 grid length' do
        @calculation.recalculate(52.7).should == 27
      end
    end
  end
  
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
picky-2.1.2 spec/lib/internals/calculations/location_spec.rb
picky-2.1.1 spec/lib/internals/calculations/location_spec.rb
picky-2.1.0 spec/lib/internals/calculations/location_spec.rb
picky-2.0.0 spec/lib/internals/calculations/location_spec.rb
picky-2.0.0.pre3 spec/lib/internals/calculations/location_spec.rb
picky-2.0.0.pre2 spec/lib/internals/calculations/location_spec.rb
picky-2.0.0.pre1 spec/lib/internals/calculations/location_spec.rb
picky-1.5.4 spec/lib/internals/calculations/location_spec.rb
picky-1.5.3 spec/lib/internals/calculations/location_spec.rb
picky-1.5.2 spec/lib/internals/calculations/location_spec.rb
picky-1.5.1 spec/lib/internals/calculations/location_spec.rb
picky-1.5.0 spec/lib/internals/calculations/location_spec.rb
picky-1.4.3 spec/lib/internals/calculations/location_spec.rb
picky-1.4.2 spec/lib/internals/calculations/location_spec.rb
picky-1.4.1 spec/lib/calculations/location_spec.rb
picky-1.4.0 spec/lib/calculations/location_spec.rb
picky-1.3.4 spec/lib/calculations/location_spec.rb
picky-1.3.3 spec/lib/calculations/location_spec.rb
picky-1.3.2 spec/lib/calculations/location_spec.rb
picky-1.3.1 spec/lib/calculations/location_spec.rb