Skip to content

Instantly share code, notes, and snippets.

Last active December 18, 2015 04:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save trishagee/5728962 to your computer and use it in GitHub Desktop.
Test for encoding lists in Spock
class IterableCodecSpecification extends Specification {
private BSONWriter bsonWriter = Mock();
private final IterableCodec iterableCodec = new IterableCodec(Codecs.createDefault());
public void 'should encode list of strings'() {
List<String> stringList = ['Uno', 'Dos', 'Tres'];
iterableCodec.encode(bsonWriter, stringList);
1 * bsonWriter.writeStartArray();
1 * bsonWriter.writeString('Uno');
1 * bsonWriter.writeString('Dos');
1 * bsonWriter.writeString('Tres');
1 * bsonWriter.writeEndArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment