require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Number to Fraction" do include ActionView::Helpers::NumberHelper it "should be blank when nil" do number_to_fraction(nil).should == '' end it "should be blank when blank" do number_to_fraction('').should == '' end it "should be 0" do number_to_fraction(0).should == '0' end it "should be 1" do number_to_fraction(1).should == '1' end it "should be 10" do number_to_fraction(10).should == "10" end it "should be 10 even when the fractional is zero" do number_to_fraction(10.0).should == "10" end it "should be 1/3" do number_to_fraction(0.33).should == "1/3" end it "should be 2/3" do number_to_fraction(0.66).should == "2/3" end it "should be 1/4" do number_to_fraction(0.25).should == "1/4" end it "should be 3/4" do number_to_fraction(0.75).should == "3/4" end it "should be 1/5" do number_to_fraction(0.2).should == "1/5" end it "should be 2/5" do number_to_fraction(0.4).should == "2/5" end it "should be 3/5" do number_to_fraction(0.6).should == "3/5" end it "should be 4/5" do number_to_fraction(0.8).should == "4/5" end it "should be 1/6" do number_to_fraction(0.166).should == "1/6" end it "should be 5/6" do number_to_fraction(0.833).should == "5/6" end it "should be 1/7" do number_to_fraction(0.142).should == "1/7" end it "should be 2/7" do number_to_fraction(0.285).should == "2/7" end it "should be 3/7" do number_to_fraction(0.428).should == "3/7" end it "should be 4/7" do number_to_fraction(0.571).should == "4/7" end it "should be 5/7" do number_to_fraction(0.714).should == "5/7" end it "should be 6/7" do number_to_fraction(0.857).should == "6/7" end it "should be 1/8" do number_to_fraction(0.125).should == "1/8" end it "should be 3/8" do number_to_fraction(0.375).should == "3/8" end it "should be 5/8" do number_to_fraction(0.625).should == "5/8" end it "should be 7/8" do number_to_fraction(0.875).should == "7/8" end it "should be 1/9" do number_to_fraction(0.11).should == "1/9" end it "should be 2/9" do number_to_fraction(0.22).should == "2/9" end it "should be 4/9" do number_to_fraction(0.44).should == "4/9" end it "should be 5/9" do number_to_fraction(0.55).should == "5/9" end it "should be 7/9" do number_to_fraction(0.77).should == "7/9" end it "should be 8/9" do number_to_fraction(0.88).should == "8/9" end it "should be 1 2/3" do number_to_fraction(1.66).should == "1 2/3" end it "should be 55 2/9" do number_to_fraction(55.22).should == "55 2/9" end it "should be 10203 3/8" do number_to_fraction(10203.375).should == "10203 3/8" end end