Sha256: 0d16d53b27f9c6cd2c22a4377999fc65fe2140424b962465bc3489d80a4eb7d0

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

# encoding: UTF-8

require 'spec_helper'

RSpec.describe Measurement do
  describe 'acre-feet' do
    subject { described_class.parse('1 acre ft') }

    it 'converts to cubic yards' do
      expect(subject.convert_to(:yd3).quantity).to eq Rational(4840, 3).to_f
    end

    it 'converts to cubic feet' do
      expect(subject.convert_to(:ft3).quantity).to eq 43_560
    end

    it 'converts to cubic inches' do
      expect(subject.convert_to(:in3).quantity).to eq 75_271_680
    end
  end

  describe 'cubic yards' do
    subject { described_class.parse('1613 1/3 yd³') }

    it 'converts to acre-feet' do
      expect(subject.convert_to(:'acre ft').quantity).to eq 1
    end

    it 'converts to cubic feet' do
      expect(subject.convert_to(:ft3).quantity).to eq 43_560
    end

    it 'converts to cubic inches' do
      expect(subject.convert_to(:in3).quantity).to eq 75_271_680
    end
  end

  describe 'cubic feet' do
    subject { described_class.parse('43560 ft³') }

    it 'converts to acre-feet' do
      expect(subject.convert_to(:'acre ft').quantity).to eq 1
    end

    it 'converts to cubic yards' do
      expect(subject.convert_to(:yd3).quantity).to eq Rational(4840, 3).to_f
    end

    it 'converts to cubic inches' do
      expect(subject.convert_to(:in3).quantity).to eq 75_271_680
    end
  end

  describe 'cubic inches' do
    subject { described_class.parse('75271680 in³') }

    it 'converts to acre-feet' do
      expect(subject.convert_to(:'acre ft').quantity).to eq 1
    end

    it 'converts to cubic yards' do
      expect(subject.convert_to(:yd3).quantity).to eq Rational(4840, 3).to_f
    end

    it 'converts to cubic feet' do
      expect(subject.convert_to(:ft3).quantity).to eq 43_560
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-measurement-1.3.0 spec/ruby-measurement/definitions/us_customary/capacity_spec.rb
ruby-measurement-1.2.3 spec/ruby-measurement/definitions/us_customary/capacity_spec.rb