spec/unit/mongoid/extensions/integer/conversions_spec.rb in mongoid-0.5.3 vs spec/unit/mongoid/extensions/integer/conversions_spec.rb in mongoid-0.5.4

- old
+ new

@@ -1,11 +1,24 @@ require File.join(File.dirname(__FILE__), "/../../../../spec_helper.rb") describe Mongoid::Extensions::Integer::Conversions do describe "#cast" do - it "converts the string to an Integer" do - Integer.cast("32").should == 32 + + context "when string is a number" do + + it "converts the string to an Integer" do + Integer.cast("32").should == 32 + end + + end + + context "when string is not a number" do + + it "returns the string" do + Integer.cast("foo").should == "foo" + end + end end end