test/test_mongoo.rb in mongoo-0.5.6 vs test/test_mongoo.rb in mongoo-0.5.7

- old
+ new

@@ -1,11 +1,11 @@ require 'helper' class TestMongoo < Test::Unit::TestCase def setup - [Person, TvShow, SearchIndex].each do |obj| + [Person, TvShow, SearchIndex, Contact].each do |obj| obj.drop obj.create_indexes end end @@ -484,9 +484,16 @@ p.mod!(q: { 'interests' => { '$size' => 4 } }) { |m| m.push("interests", "base jumping") } assert_equal ["skydiving", "coding", "reading", "swimming", "base jumping"], p.interests p = Person.find_one(p.id) assert_equal ["skydiving", "coding", "reading", "swimming", "base jumping"], p.interests + end + + should "raise a specific error if a unique constraint is violated" do + c = Contact.new(email: "foo@bar.com") + assert c.insert! + c = Contact.new(email: "foo@bar.com") + assert_raise(Mongoo::DuplicateKeyError) { c.insert! } end end