Last active
December 18, 2015 04:59
-
-
Save trishagee/5728962 to your computer and use it in GitHub Desktop.
Test for encoding lists in Spock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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