Skip to content

Commit

Permalink
Refactor all specs to use proper matchers:
Browse files Browse the repository at this point in the history
- should == value becomes should eq(value)
- should == true becomes should be_true
- should == false becomes should be_false
- should == nil becomes should be_nil
- should == [] becomes should be_empty
- Part 3 of #1286.
  • Loading branch information
durran committed Jan 19, 2012
1 parent c9ea7ae commit 37aedf3
Show file tree
Hide file tree
Showing 123 changed files with 1,718 additions and 1,650 deletions.
48 changes: 27 additions & 21 deletions spec/mongoid/atomic/paths_spec.rb
Expand Up @@ -28,14 +28,14 @@
context "when document is an embeds_one" do

it "returns $unset" do
name.atomic_delete_modifier.should == "$unset"
name.atomic_delete_modifier.should eq("$unset")
end
end

context "when document is an embeds_many" do

it "returns $pull" do
address.atomic_delete_modifier.should == "$pull"
address.atomic_delete_modifier.should eq("$pull")
end
end
end
Expand All @@ -50,14 +50,14 @@
context "when document is an embeds_one" do

it "returns $set" do
name.atomic_insert_modifier.should == "$set"
name.atomic_insert_modifier.should eq("$set")
end
end

context "when document is an embeds_many" do

it "returns $push" do
address.atomic_insert_modifier.should == "$push"
address.atomic_insert_modifier.should eq("$push")
end
end
end
Expand All @@ -67,7 +67,7 @@
context "when the document is a parent" do

it "returns an empty string" do
person.atomic_path.should == ""
person.atomic_path.should be_empty
end
end

Expand All @@ -78,7 +78,7 @@
end

it "returns the inverse_of value of the association" do
address.atomic_path.should == "addresses"
address.atomic_path.should eq("addresses")
end
end

Expand All @@ -90,7 +90,7 @@
end

it "returns the JSON notation to the document" do
location.atomic_path.should == "addresses.locations"
location.atomic_path.should eq("addresses.locations")
end
end
end
Expand All @@ -100,7 +100,7 @@
context "when the document is a parent" do

it "returns an id.atomic_selector" do
person.atomic_selector.should == { "_id" => person.id }
person.atomic_selector.should eq({ "_id" => person.id })
end
end

Expand All @@ -111,7 +111,9 @@
end

it "returns the association with id.atomic_selector" do
address.atomic_selector.should == { "_id" => person.id, "addresses._id" => address.id }
address.atomic_selector.should eq(
{ "_id" => person.id, "addresses._id" => address.id }
)
end
end

Expand All @@ -123,8 +125,13 @@
end

it "returns the JSON notation to the document with ids" do
location.atomic_selector.should ==
{ "_id" => person.id, "addresses._id" => address.id, "addresses.locations._id" => location.id }
location.atomic_selector.should eq(
{
"_id" => person.id,
"addresses._id" => address.id,
"addresses.locations._id" => location.id
}
)
end
end
end
Expand All @@ -134,7 +141,7 @@
context "when the document is a parent" do

it "returns an empty string" do
person.atomic_position.should == ""
person.atomic_position.should be_empty
end
end

Expand All @@ -147,7 +154,7 @@
context "when the document is new" do

it "returns the.atomic_path without index" do
address.atomic_position.should == "addresses"
address.atomic_position.should eq("addresses")
end
end

Expand All @@ -158,7 +165,7 @@
end

it "returns the.atomic_path plus index" do
address.atomic_position.should == "addresses.0"
address.atomic_position.should eq("addresses.0")
end
end
end
Expand All @@ -178,7 +185,7 @@
context "when the document is new" do

it "returns the.atomic_path with parent indexes" do
location.atomic_position.should == "addresses.0.locations"
location.atomic_position.should eq("addresses.0.locations")
end
end

Expand All @@ -189,7 +196,7 @@
end

it "returns the.atomic_path plus index" do
location.atomic_position.should == "addresses.0.locations.1"
location.atomic_position.should eq("addresses.0.locations.1")
end
end
end
Expand All @@ -200,7 +207,7 @@
context "when the document is a parent" do

it "returns an empty string" do
person.atomic_path.should == ""
person.atomic_path.should be_empty
end
end

Expand All @@ -217,7 +224,7 @@
end

it "returns the.atomic_path without the index" do
address.atomic_path.should == "addresses"
address.atomic_path.should eq("addresses")
end

context "and there are 10 or more documents" do
Expand All @@ -229,9 +236,8 @@
end

it "returns the.atomic_path without the index" do
address.atomic_path.should == "addresses"
address.atomic_path.should eq("addresses")
end

end
end
end
Expand All @@ -255,7 +261,7 @@
end

it "returns the.atomic_path plus index" do
location.atomic_path.should == "addresses.0.locations"
location.atomic_path.should eq("addresses.0.locations")
end

end
Expand Down
25 changes: 16 additions & 9 deletions spec/mongoid/atomic_spec.rb
Expand Up @@ -21,7 +21,7 @@
end

it "returns the atomic updates" do
person.atomic_updates.should == { "$set" => { "title" => "Sir" } }
person.atomic_updates.should eq({ "$set" => { "title" => "Sir" }})
end

context "when an embeds many child is added" do
Expand All @@ -31,13 +31,14 @@
end

it "returns a $set and $pushAll for modifications" do
person.atomic_updates.should ==
person.atomic_updates.should eq(
{
"$set" => { "title" => "Sir" },
"$pushAll" => { "addresses" => [
{ "_id" => "oxford-st", "street" => "Oxford St" }
]}
}
)
end
end

Expand All @@ -48,13 +49,14 @@
end

it "returns a $set for modifications" do
person.atomic_updates.should ==
person.atomic_updates.should eq(
{
"$set" => {
"title" => "Sir",
"name" => { "_id" => "Lionel-", "first_name" => "Lionel" }
}
}
)
end
end

Expand All @@ -69,8 +71,9 @@
end

it "returns the $set with correct position and modifications" do
person.atomic_updates.should ==
{ "$set" => { "title" => "Sir", "addresses.0.street" => "Bond St" } }
person.atomic_updates.should eq(
{ "$set" => { "title" => "Sir", "addresses.0.street" => "Bond St" }}
)
end

context "when an existing 2nd level embedded child gets modified" do
Expand All @@ -84,12 +87,13 @@
end

it "returns the $set with correct positions and modifications" do
person.atomic_updates.should ==
person.atomic_updates.should eq(
{ "$set" => {
"title" => "Sir",
"addresses.0.street" => "Bond St",
"addresses.0.locations.0.name" => "Work" }
}
)
end
end

Expand All @@ -100,7 +104,7 @@
end

it "returns the $set with correct positions and modifications" do
person.atomic_updates.should ==
person.atomic_updates.should eq(
{
"$set" => {
"title" => "Sir",
Expand All @@ -112,6 +116,7 @@
}
}
}
)
end
end

Expand Down Expand Up @@ -144,7 +149,7 @@
end

it "returns the $set for 1st level and other for the 2nd level" do
person.atomic_updates.should ==
person.atomic_updates.should eq(
{
"$set" => {
"title" => "Sir",
Expand All @@ -163,6 +168,7 @@
}
}
}
)
end
end
end
Expand All @@ -178,7 +184,7 @@
end

it "returns the proper $sets and $pushAlls for all levels" do
person.atomic_updates.should ==
person.atomic_updates.should eq(
{
"$set" => {
"title" => "Sir",
Expand All @@ -194,6 +200,7 @@
}]
}
}
)
end
end
end
Expand Down

0 comments on commit 37aedf3

Please sign in to comment.