Permalink
Browse files

Move test to spec file

  • Loading branch information...
1 parent e0175bf commit ae096ffc570f828db1a8bc9928018234aceccad9 @lsegal committed Nov 26, 2009
Showing with 28 additions and 27 deletions.
  1. +0 −27 lib/odb.rb
  2. +28 −0 spec/persistence_spec.rb
View
@@ -234,30 +234,3 @@ def __deserialize__(db = nil)
nil
end
end
-
-class Post
- include ODB::Persistent
- attr_accessor :title, :author, :comment
-end
-
-class Comment
- include ODB::Persistent
-
- def initialize
- @name = 1
- @value = 2.5
- end
-end
-
-db = ODB.new(ODB::FileStore.new("hello"))
-db.transaction do
- post = Post.new.tap {|p| p.title = "x"; p.author = "Joe"; p.comment = Comment.new }
- db.store[:post] = post
- db.store[:comment] = post.comment
-end
-
-p db.store[:post]
-# #<Post:0x100123170 @comment=#<Comment:0x100123030 @name=1, @value=2.5>, @author="Joe", @title="x">
-
-p db.store[:post].comment.object_id == db.store[:comment].object_id
-# true
@@ -0,0 +1,28 @@
+require File.dirname(__FILE__) + "/../lib/odb"
+
+class Post
+ include ODB::Persistent
+ attr_accessor :title, :author, :comment
+end
+
+class Comment
+ def initialize
+ @name = 1
+ @value = 2.5
+ end
+end
+
+describe ODB::Persistent do
+ it "should save a post" do
+ db = ODB.new
+ post = Post.new.tap {|p| p.title = "x"; p.author = "Joe"; p.comment = Comment.new }
+ db.transaction do
+ db.store[:post] = post
+ db.store[:comment] = post.comment
+ end
+
+ db.store[:post].should == post
+ db.store[:post].comment.object_id.should == db.store[:comment].object_id
+ end
+end
+

0 comments on commit ae096ff

Please sign in to comment.