Context: I've created a new plugin named AppDomain that includes the Mongo 3.0.1 plugin. It has one domain class (Person), and one integration test (PersonSpec).
Issue: The id is being generated. The appdomain database and person collection are being created in Mongo. However, the integration test is failing at the collection count.
Notes: Having consulted all documentation that I could find and having made the bare minimum of changes to the generated AppDomain plugin code, I'm at a loss as to why the persistence test included here is failing. I have a similar plugin configured with grails 2.2.2 using junit tests that works just fine.
Any help is appreciated.
package appdomain
class Person {
String firstName
String lastName
}
-
package appdomain
import grails.test.mixin.TestMixin
import grails.test.mixin.mongodb.*
import spock.lang.*
@TestMixin(MongoDbTestMixin)
class PersonSpec extends Specification {
def setup() {
}
def cleanup() {
}
void "can persist a person to the appdomain mongo database"() {
given: "a person"
def aPerson = new Person(firstName: "Homer", lastName: "Simpson")
when: "the person is saved"
aPerson.save()
then: "the person has an id"
aPerson.id != null //Passes
and: "the Person collection contains one item"
Person.list().size() == 1 //Fails with Person.list().size() == 0
}
}