spec/mongo/fixture_spec.rb in mongo-fixture-0.0.3 vs spec/mongo/fixture_spec.rb in mongo-fixture-0.0.4
- old
+ new
@@ -435,11 +435,11 @@
it "should insert the comment so that the comment user value matches the '_id' of the user" do
database = double 'database'
comm = double 'comments', :count => 0, :drop => nil
comm.should_receive( :insert ).with( :user => "un id", :text => "FLAME" )
record = stub 'record'
- record.should_receive( :[] ).with( :_id ).and_return "un id"
+ record.should_receive( :[] ).with( "_id" ).and_return "un id"
usrs = double 'users', :count => 0, :find => stub( :first => record ), :drop => nil, :insert => nil
database.stub :[] do |coll|
case coll
when :users
usrs
@@ -628,8 +628,44 @@
it "should call drop on each of the used collections" do
@truncable.should_receive(:drop).exactly(3).times
@fix.rollback
end
+ end
+ end
+
+ context "two collections are to be inserted with references" do
+ before do
+ Fast.file.write "test/fixtures/references/users.yaml", "pepe:
+ username: pepe
+ password:
+ raw: secreto
+ processed: 252db48960f032db4bb604bc26f97106fa85ff88dedef3a28671b6bcd9f9644bf90d7e444d587c9351dfa237a6fc8fe38641a8469d084a166c7807d9c6564860
+ name: Pepe"
+ Fast.file.write "test/fixtures/references/sessions.yaml", "14_horas:
+ user:
+ users: pepe
+ time: 2012-07-30T14:02:40-03:00
+ y_tres_minutos:
+ user:
+ users: pepe
+ time: 2012-07-30T14:03:40-03:00
+ y_cuatro_minutos:
+ user:
+ users: pepe
+ time: 2012-07-30T14:04:40-03:00"
+ end
+
+ it "should not fail!" do
+ collection = double 'coll', :count => 0, :insert => nil
+ database = double 'database'
+ database.stub :[] do |argument|
+ collection
+ end
+ Mongo::Fixture.new :references, database
+ end
+
+ after do
+ Fast.dir.remove! :test
end
end
end