Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e97ab4cd96
Fetching contributors…

Cannot retrieve contributors at this time

file 42 lines (31 sloc) 1.026 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
require File.expand_path(File.dirname(__FILE__) + '/support/integration_helper')

LightMongo.slow_serialization = true

class Article
  include LightMongo::Document

  attr_accessor :title, :comments

  def initialize(*args)
    @comments = []
    super
  end
end

class Comment
  attr_accessor :author_name, :text
end

describe 'Embedding a Ruby object within your LightMongo::Document' do
  before(:each) do
    @geology_article = Article.create(:title => (@title = 'Fluid Physics in Geology'))

    @comment = Comment.new
    @comment.author_name = 'Dave'
    @comment.text = "Cool article!"
    
    @geology_article.comments << @comment
    @geology_article.save
  end
  
  it "is represented as embedded MongoDB documents and eager restored." do
    stored_article = Article.find.first
    stored_article.title.should == @title
    
    stored_comment = stored_article.comments.first
    stored_comment.author_name.should == @comment.author_name
    stored_comment.text.should == @comment.text
  end
  
  db_teardown
end
Something went wrong with that request. Please try again.