Sha256: 1884c8c0e887790df65367616c621f3c914be2df4c40718e2f92ce5b52dd1a7a

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

require File.join(File.dirname(__FILE__),"../lib/icecream/parser")

describe "Parser" do
  describe "Parsing a file into an array" do
    before(:all) do
      @path = File.join(File.dirname(__FILE__),"../spec/flavors/chocolate.flavor")
    end
    it "Gets the object" do
      obj = IceCream::Parser.get_flavor @path
      obj.class.should be Chocolate
    end
    it "Gets the string between two strings" do
      IceCream::Parser.slice_between_strings("/super/flavors/chocolate.flavor", "/flavors/", ".flavor")
      .should == "chocolate"
    end
    it "Gets the name of the future object" do
      IceCream::Parser.get_flavor_name(@path).should == "chocolate"
    end
    it "Returns the right type of the value" do
      
      # Strings
      IceCream::Parser.fix_value("\"chocolate\"").should == "chocolate"
      IceCream::Parser.fix_value("\"15\"").should == "15"
      
      # Symbles
      IceCream::Parser.fix_value(":i15").should == :i15

      # Float
      IceCream::Parser.fix_value("15.5").should == 15.5
      
      # Int
      IceCream::Parser.fix_value("15").should == 15

      # Invalid conversions
      IceCream::Parser.fix_value("15s").should == ""
      
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
icecream-0.0.6 spec/parser_spec.rb
icecream-0.0.5 spec/parser_spec.rb
icecream-0.0.4 spec/parser_spec.rb
icecream-0.0.3 spec/parser_spec.rb
icecream-0.0.2 spec/parser_spec.rb