Sha256: 6662eb12ad723c5b5066220758a7c01a3fe2aba9b0fda6aee414026fea23ceb1

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 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

1 entries across 1 versions & 1 rubygems

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