Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test for encoding lists in Spock
class IterableCodecSpecification extends Specification {
private BSONWriter bsonWriter = Mock();
@Subject
private final IterableCodec iterableCodec = new IterableCodec(Codecs.createDefault());
public void 'should encode list of strings'() {
setup:
List<String> stringList = ['Uno', 'Dos', 'Tres'];
when:
iterableCodec.encode(bsonWriter, stringList);
then:
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