spec/integration/mongoid/document_spec.rb in mongoid-pre-2.0.0.beta1 vs spec/integration/mongoid/document_spec.rb in mongoid-pre-2.0.0.pre
- old
+ new
@@ -119,16 +119,10 @@
it "deletes the document" do
@person.destroy
lambda { Person.find(@person.id) }.should raise_error
end
- it "marks the document as destroyed" do
- @person.should_not be_destroyed
- @person.destroy
- @person.should be_destroyed
- end
-
end
context "on an embedded document" do
before do
@@ -248,11 +242,11 @@
describe "#group" do
before do
5.times do |num|
- Person.create(:title => "Sir", :age => num, :ssn => num)
+ Person.create(:title => "Sir", :age => num)
end
end
it "returns grouped documents" do
grouped = Person.only(:title).group
@@ -289,11 +283,11 @@
before do
@person = Person.new
end
it "returns a pretty string of class name and attributes" do
- attrs = Person.fields.map { |name, field| "#{name}: #{@person.attributes[name].nil? ? 'nil' : @person.attributes[name]}" } * ", "
+ attrs = Person.fields.map { |name, field| "#{name}: #{@person.attributes[name] || 'nil'}" } * ", "
@person.inspect.should == "#<Person _id: #{@person.id}, #{attrs}>"
end
end
@@ -329,14 +323,10 @@
it "reloads the obejct attributes from the db" do
@person.reload
@person.age.should == 35
end
- it "reload should return self" do
- @person.reload.should == @from_db
- end
-
end
describe "#save" do
context "on a has_one association" do
@@ -425,11 +415,11 @@
@person.name = @name
@person.addresses << @home
@person.addresses << @business
end
- it "allows adding multiples on an embeds_many in a row" do
+ it "allows adding multiples on a has_many in a row" do
@person.addresses.length.should == 2
end
context "when saving on a has_one" do
@@ -442,17 +432,17 @@
person.should == @person
end
end
- context "when saving on an embeds_many" do
+ context "when saving on a has_many" do
before do
@home.save
end
- it "saves the entire graph up from the embeds_many" do
+ it "saves the entire graph up from the has_many" do
person = Person.first(:conditions => { :title => "Sir" })
person.should == @person
end
end
@@ -494,66 +484,9 @@
it "returns the json string" do
@person.save
from_db = Person.find(@person.id)
from_db.to_json.should == from_db.attributes.to_json
- end
-
- end
-
- end
-
- describe "#as_json" do
-
- before do
- @person = Person.new(:title => "Sir", :age => 30)
- @address = Address.new(:street => "Nan Jing Dong Lu")
- @person.addresses << @address
- end
-
- context "on a new document" do
-
- it "returns the attributes" do
- @person.as_json.should == @person.attributes
- end
-
- end
-
- context "on a persisted document" do
-
- it "returns the attributes" do
- @person.save
- from_db = Person.find(@person.id)
- from_db.as_json.should == from_db.attributes
- end
-
- end
-
- end
-
- describe "#encode_json" do
-
- before do
- @person = Person.new(:title => "Sir", :age => 30)
- @address = Address.new(:street => "Nan Jing Dong Lu")
- @person.addresses << @address
- @encoder = Array.new
- end
-
- context "on a new document" do
-
- it "returns the attributes" do
- @person.encode_json(@encoder).should == @person.attributes
- end
-
- end
-
- context "on a persisted document" do
-
- it "returns the attributes" do
- @person.save
- from_db = Person.find(@person.id)
- from_db.encode_json(@encoder).should == from_db.attributes
end
end
end