spec/mongoid/extensions/string_spec.rb in mongoid-3.1.7 vs spec/mongoid/extensions/string_spec.rb in mongoid-4.0.0.alpha1
- old
+ new
@@ -5,65 +5,65 @@
describe "#__evolve_object_id__" do
context "when the string is blank" do
it "returns the empty string" do
- "".__evolve_object_id__.should be_empty
+ expect("".__evolve_object_id__).to be_empty
end
end
context "when the string is a legal object id" do
let(:object_id) do
- Moped::BSON::ObjectId.new
+ BSON::ObjectId.new
end
it "returns the object id" do
- object_id.to_s.__evolve_object_id__.should eq(object_id)
+ expect(object_id.to_s.__evolve_object_id__).to eq(object_id)
end
end
context "when the string is not a legal object id" do
let(:string) do
"testing"
end
it "returns the string" do
- string.__evolve_object_id__.should eq(string)
+ expect(string.__evolve_object_id__).to eq(string)
end
end
end
describe "#__mongoize_object_id__" do
context "when the string is blank" do
it "returns nil" do
- "".__mongoize_object_id__.should be_nil
+ expect("".__mongoize_object_id__).to be_nil
end
end
context "when the string is a legal object id" do
let(:object_id) do
- Moped::BSON::ObjectId.new
+ BSON::ObjectId.new
end
it "returns the object id" do
- object_id.to_s.__mongoize_object_id__.should eq(object_id)
+ expect(object_id.to_s.__mongoize_object_id__).to eq(object_id)
end
end
context "when the string is not a legal object id" do
let(:string) do
"testing"
end
it "returns the string" do
- string.__mongoize_object_id__.should eq(string)
+ expect(string.__mongoize_object_id__).to eq(string)
end
end
end
describe "#__mongoize_time__" do
@@ -88,15 +88,15 @@
let(:time) do
string.__mongoize_time__
end
it "converts to a time" do
- time.should eq(Time.configured.parse(string))
+ expect(time).to eq(Time.configured.parse(string))
end
it "converts to the as time zone" do
- time.zone.should eq("JST")
+ expect(time.zone).to eq("JST")
end
end
context "when the string is an invalid time" do
@@ -132,11 +132,11 @@
let(:time) do
string.__mongoize_time__
end
it "converts to a time" do
- time.should eq(Time.parse(string))
+ expect(time).to eq(Time.parse(string))
end
end
context "when the string is an invalid time" do
@@ -162,206 +162,195 @@
include Mongoid::Document
end
end
it "returns an underscored tableized name" do
- Medical::Patient.name.collectionize.should eq("medical_patients")
+ expect(Medical::Patient.name.collectionize).to eq("medical_patients")
end
end
context "when class is not namespaced" do
it "returns an underscored tableized name" do
- MixedDrink.name.collectionize.should eq("mixed_drinks")
+ expect(MixedDrink.name.collectionize).to eq("mixed_drinks")
end
end
end
describe ".demongoize" do
context "when the object is not a string" do
it "returns the string" do
- String.demongoize(:test).should eq("test")
+ expect(String.demongoize(:test)).to eq("test")
end
end
context "when the object is nil" do
it "returns nil" do
- String.demongoize(nil).should be_nil
+ expect(String.demongoize(nil)).to be_nil
end
end
end
describe "#mongoid_id?" do
context "when the string is id" do
it "returns true" do
- "id".should be_mongoid_id
+ expect("id").to be_mongoid_id
end
end
context "when the string is _id" do
it "returns true" do
- "_id".should be_mongoid_id
+ expect("_id").to be_mongoid_id
end
end
context "when the string contains id" do
it "returns false" do
- "identity".should_not be_mongoid_id
+ expect("identity").to_not be_mongoid_id
end
end
context "when the string contains _id" do
it "returns false" do
- "something_id".should_not be_mongoid_id
+ expect("something_id").to_not be_mongoid_id
end
end
end
describe ".mongoize" do
context "when the object is not a string" do
it "returns the string" do
- String.mongoize(:test).should eq("test")
+ expect(String.mongoize(:test)).to eq("test")
end
end
context "when the object is nil" do
it "returns nil" do
- String.mongoize(nil).should be_nil
+ expect(String.mongoize(nil)).to be_nil
end
end
end
describe "#mongoize" do
it "returns self" do
- "test".mongoize.should eq("test")
+ expect("test".mongoize).to eq("test")
end
end
describe "#reader" do
context "when string is a reader" do
it "returns self" do
- "attribute".reader.should eq("attribute")
+ expect("attribute".reader).to eq("attribute")
end
end
context "when string is a writer" do
it "returns the reader" do
- "attribute=".reader.should eq("attribute")
+ expect("attribute=".reader).to eq("attribute")
end
end
context "when the string is before_type_cast" do
it "returns the reader" do
- "attribute_before_type_cast".reader.should eq("attribute")
+ expect("attribute_before_type_cast".reader).to eq("attribute")
end
end
end
describe "#numeric?" do
context "when the string is an integer" do
it "returns true" do
- "1234".should be_numeric
+ expect("1234").to be_numeric
end
end
context "when string is a float" do
it "returns true" do
- "1234.123".should be_numeric
+ expect("1234.123").to be_numeric
end
end
context "when the string is has exponents" do
it "returns true" do
- "1234.123123E4".should be_numeric
+ expect("1234.123123E4").to be_numeric
end
end
context "when the string is non numeric" do
it "returns false" do
- "blah".should_not be_numeric
+ expect("blah").to_not be_numeric
end
end
end
describe "#singularize" do
context "when string is address" do
it "returns address" do
- "address".singularize.should eq("address")
+ expect("address".singularize).to eq("address")
end
end
context "when string is address_profiles" do
it "returns address_profile" do
- "address_profiles".singularize.should eq("address_profile")
+ expect("address_profiles".singularize).to eq("address_profile")
end
end
end
- describe "#to_a" do
-
- let(:value) do
- "Disintegration is the best album ever!"
- end
-
- it "returns an array with the string in it" do
- value.to_a.should eq([ value ])
- end
- end
-
describe "#writer?" do
context "when string is a reader" do
it "returns false" do
- "attribute".writer?.should be_false
+ expect("attribute".writer?).to be false
end
end
context "when string is a writer" do
it "returns true" do
- "attribute=".writer?.should be_true
+ expect("attribute=".writer?).to be true
end
end
end
describe "#before_type_cast?" do
context "when string is a reader" do
it "returns false" do
- "attribute".before_type_cast?.should be_false
+ expect("attribute".before_type_cast?).to be false
end
end
context "when string is before_type_cast" do
it "returns true" do
- "attribute_before_type_cast".before_type_cast?.should be_true
+ expect("attribute_before_type_cast".before_type_cast?).to be true
end
end
end
end