require 'spec_helper' describe Numeric do describe "#multiple_of?" do it "to be true" do expect(9.multiple_of?(3)).to eq(true) end it "to be false" do expect(10.multiple_of?(3)).to eq(false) end end describe "#negative?" do it "to be true" do expect(-1.negative?).to eq(true) end it "to be false" do expect(1.negative?).to eq(false) end end describe "#positive?" do it "to be true" do expect(1.positive?).to eq(true) end it "to be false" do expect(-1.positive?).to eq(false) end end describe "#to_byte" do it "to be 1" do expect(1024.to_byte).to eq(1) expect(1024.to_byte(:kb, :mb)).to eq(1) end it "to be 5" do expect(5120.to_byte).to eq(5) expect(5120.to_byte(:kb, :mb)).to eq(5) end it "to be 1024" do expect(1024.to_byte(:kb, :kb)).to eq(1024) expect(1.to_byte(:mb, :kb)).to eq(1024) end it "to be 1048576" do expect(1.to_byte(:gb, :kb)).to eq(1048576) end it "to be 0.078125" do expect(80.to_byte(:mb, :gb)).to eq(0.078125) end end describe "#to_length" do it "to be 0.039370078740157" do expect(1.to_length).to eq(0.039370078740157) end it "to be 1" do expect(1.to_length(:mm, :mm)).to eq(1) expect(1.to_length(:in, :in)).to eq(1) expect(10.to_length(:mm, :cm)).to eq(1) expect(12.to_length(:in, :ft)).to eq(1) end it "to be 10" do expect(1.to_length(:cm, :mm)).to eq(10) end it "to be 12" do expect(1.to_length(:ft, :in)).to eq(12) end it "to be 30.48" do expect(1.to_length(:ft, :cm)).to eq(30.48) end it "to be 1093.6132983377001" do expect(1.to_length(:km, :yd)).to eq(1093.6132983377001) end it "to be 6076.116666666666" do expect(1.to_length(:nm, :ft)).to eq(6076.116666666666) end end describe "#to_temperature" do it "to be 212" do expect(100.to_temperature).to eq(212) expect(100.to_temperature(:c, :f)).to eq(212) expect(100.to_temperature(:celcius, :fahrenheit)).to eq(212) end it "to be 100" do expect(100.to_temperature(:c, :c)).to eq(100) expect(212.to_temperature(:f, :c)).to eq(100) end it "to be 373.15" do expect(100.to_temperature(:c, :k)).to eq(373.15) expect(212.to_temperature(:f, :k)).to eq(373.15) end end describe "#to_weight" do it "to be 0.035273961949580004" do expect(1.to_weight).to eq(0.035273961949580004) end it "to be 1" do expect(1.to_weight(:mg, :mg)).to eq(1) expect(1.to_weight(:oz, :oz)).to eq(1) expect(10.to_weight(:mg, :cg)).to eq(1) expect(16.to_weight(:oz, :lb)).to eq(1) end it "to be 1.3607771100000001" do expect(3.to_weight(:lb, :kg)).to eq(1.3607771100000001) end it "to be 1.1023113109243998" do expect(1.to_weight(:mt, :tn)).to eq(1.1023113109243998) end it "to be 2.2046226218488" do expect(1.to_weight(:kg, :lb)).to eq(2.2046226218488) end it "to be 10" do expect(1.to_weight(:cg, :mg)).to eq(10) end it "to be 16" do expect(1.to_weight(:lb, :oz)).to eq(16) end it "to be 64000" do expect(2.to_weight(:tn, :lb)).to eq(4000) end end end