Sha256: 8ddedc162361392e3334c53e76b418d70b9e56ad71e6e6cdadbb15a4dedb0459

Contents?: true

Size: 658 Bytes

Versions: 3

Compression:

Stored size: 658 Bytes

Contents

require "units_converter"

RSpec::Matchers.define(:be_converted_to) do |new_quantity_and_unit|
  new_quantity = BigDecimal.new(new_quantity_and_unit[0])
  new_unit = new_quantity_and_unit[1]

  match do |old_quantity_and_unit|
    old_quantity = BigDecimal.new(old_quantity_and_unit[0])
    old_unit = old_quantity_and_unit[1]
    UnitsConverter.convert(old_quantity, old_unit).to(new_unit) == new_quantity
  end

  failure_message do |old_quantity_and_unit|
    old_quantity = BigDecimal.new(old_quantity_and_unit[0])
    old_unit = old_quantity_and_unit[1]

    "expected that #{old_quantity} #{old_unit} in #{new_unit} would be #{new_quantity}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
units_converter-0.0.3 spec/spec_helper.rb
units_converter-0.0.2 spec/spec_helper.rb
units_converter-0.0.1 spec/spec_helper.rb