test/document_test.rb in mattly-exegesis-0.2.6 vs test/document_test.rb in mattly-exegesis-0.2.8

- old
+ new

@@ -21,12 +21,32 @@ class UniqueIdBlockTestDocument include Exegesis::Document unique_id {|doc, attempt| attempt.zero? ? doc['pk'] : "#{doc['pk']}-#{attempt}" } end +module DocumentSingletonDatabaseTest + extend self + extend Exegesis::Database::Singleton +end +class SingletonDatabaseDocument + include Exegesis::Document + database DocumentSingletonDatabaseTest +end + describe Exegesis::Document do describe "class definitions" do + describe "with database declarations" do + before do + @doc = SingletonDatabaseDocument.new + end + + expect { SingletonDatabaseDocument.database.must_equal DocumentSingletonDatabaseTest } + expect { @doc.database.must_equal DocumentSingletonDatabaseTest } + + expect { lambda{SingletonDatabaseDocument.database("foo")}.must_raise(ArgumentError) } + end + describe "with timestamps" do before do reset_db @obj = TimestampTestDocument.new({}, @db) @obj.save