Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class DBCollectionSpecification extends Specification {
private final Mongo mongo = Mock()
private final ServerSelectingSession session = Mock()
private final DB database = new DB(mongo, 'myDatabase', new DocumentCodec())
@Subject
private final DBCollection collection = new DBCollection('collectionName', database, new DocumentCodec())
def setup() {
mongo.getSession() >> { session }
}
def 'should throw com.mongodb.MongoException if rename fails'() {
setup:
session.execute(_) >> { throw new org.mongodb.MongoException('The error from the new Java layer') }
when:
collection.rename('newCollectionName');
then:
thrown(com.mongodb.MongoException)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment