Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tests for document on document not valid exception

  • Loading branch information...
commit f1e55dc9c8e9eb1c786d232e2a02e4e25d850966 1 parent 4822f86
@jnunemaker jnunemaker authored
View
9 test/functional/test_validations.rb
@@ -33,6 +33,15 @@ class ValidationsTest < Test::Unit::TestCase
doc = @document.new
lambda { doc.save! }.should raise_error(MongoMapper::DocumentNotValid)
end
+
+ should "set document on exception" do
+ doc = @document.new
+ begin
+ doc.save!
+ rescue MongoMapper::DocumentNotValid => e
+ e.document.should == doc
+ end
+ end
end
context "Creating a document that is invalid (destructive)" do
View
12 test/unit/test_exceptions.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+
+class ExtensionsTest < Test::Unit::TestCase
+ context "DocumentNotValid" do
+ should "have document reader method" do
+ doc_class = Doc()
+ instance = doc_class.new
+ exception = MongoMapper::DocumentNotValid.new(instance)
+ exception.document.should == instance
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.