Skip to content

Instantly share code, notes, and snippets.

@trishagee
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();
@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