jackmiras
08/02/2017, 3:34 PMgiven("a runSeedsAndConnect call") {
on("the attempt to create a datastore") {
val spy = spy(MongoDatabaseConnection())
it("should return a non null value") {
val datastore = mongoDatabaseConnection.runSeedsAndConnect()
datastore.shouldNotBeNull()
}
it("should return a Datastore instance") {
val datastore = mongoDatabaseConnection.runSeedsAndConnect()
datastore shouldBeInstanceOf Datastore::class
}
it("should call createDatastore function") {
spy.runSeedsAndConnect()
verify(spy, times(1)).createDatastore()
}
it("should call runSeeds function") {
val datastore = mongoDatabaseConnection.createDatastore()
spy.runSeedsAndConnect()
verify(spy, times(2)).runSeeds(datastore)
}
}
}
The problem happens int the test it("should call runSeeds function") when the verify(spy, times(2).runSeeds(datastore)) is invoked. For some reason that I don't know I can't call the verify(...) function more than once when I'm using a partial mock.