test/test_embedded.rb in mongoo-0.4.6 vs test/test_embedded.rb in mongoo-0.4.7

- old
+ new

@@ -5,19 +5,19 @@ attribute "chapters", :type => :array attribute "authors", :type => :hash attribute "sample_chapter", :type => :hash def chapters - @chapters ||= embedded_array_proxy((g('chapters') || s('chapters',[])), Book::Chapter) + @chapters ||= embedded_array_proxy(get_or_set('chapters',[]), Book::Chapter) end def authors - @authors ||= embedded_hash_proxy((g('authors') || s('authors', {})), Book::Author) + @authors ||= embedded_hash_proxy(get_or_set('authors', {}), Book::Author) end def sample_chapter - @sample_chapter ||= embedded_doc((g('sample_chapter') || s('sample_chapter', {})), Book::Chapter) + @sample_chapter ||= embedded_doc(get_or_set('sample_chapter', {}), Book::Chapter) end end class Book::Chapter < Mongoo::Embedded::Base attribute "title", :type => :string @@ -50,9 +50,11 @@ assert_equal b.chapters.range(0,0), b2.chapters.range(1,1) assert_not_equal b.chapters.range(0,0), b2.chapters.range(0,0) assert_equal 2, b2.chapters.size + + assert_equal "How to Transcend Fear", b2.chapters[0].title end should "be able to work with embedded doc hashes" do b = Book.new b.authors["primary"] = b.authors.build(first_name: "Ben", last_name: "Myles") \ No newline at end of file