Sha256: 6ba3a261c9e757b9547798affb0b21ae2d72ed6410274172598b15ec2a175e52

Contents?: true

Size: 514 Bytes

Versions: 1

Compression:

Stored size: 514 Bytes

Contents

require 'spec_helper'

module Precision
  describe Calculator do

    scenarios = {
      nil => 0,
      "0.0" => 0,
      "1.0" => 0,
      "1.1" => 1,
      "10.0" => 0,
      "10.12" => 2,
      10.12 => 2,
      BigDecimal("10.111") => 3,
      1 => 0
    }

    scenarios.each do |decimal, precision|
      it "expects #{decimal.inspect} to have precision of #{precision}" do
        calculator = described_class.new(decimal)
        expect(calculator.calculate).to eq precision
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
precision-0.0.1 spec/lib/precision/calculator_spec.rb