spec/unit/mongoid/extensions/integer/conversions_spec.rb in mongoid-1.0.5 vs spec/unit/mongoid/extensions/integer/conversions_spec.rb in mongoid-1.0.6
- old
+ new
@@ -2,31 +2,59 @@
describe Mongoid::Extensions::Integer::Conversions do
describe "#set" do
- context "when string is a number" do
+ context "when the value is a number" do
- it "converts the string to an Integer" do
- Integer.set("32").should == 32
+ it "converts the number to an integer" do
+ Integer.set(3).should == 3
end
end
- context "when string is not a number" do
+ context "when the string is not a number" do
- it "returns the string" do
- Integer.set("foo").should == "foo"
+ context "when the string is non numerical" do
+
+ it "returns the string" do
+ Integer.set("foo").should == "foo"
+ end
+
end
+ context "when the string is numerical" do
+
+ it "returns the integer value for the string" do
+ Integer.set("3").should == 3
+ end
+
+ end
+
+ context "when the string is empty" do
+
+ it "returns an empty string" do
+ Integer.set("").should be_blank
+ end
+
+ end
+
+ context "when the string is nil" do
+
+ it "returns nil" do
+ Integer.set(nil).should be_nil
+ end
+
+ end
+
end
end
describe "#get" do
it "returns the integer" do
- Integer.get(44).should == 44
+ Integer.get(3).should == 3
end
end
end