@Test
public void shouldCorrectlyWriteCodeWithScope() {

    BasicDocument scope = new BasicDocument();
    scope.put("firstName", "Jack");
    scope.put("lastName", "Riley");
    CodeWithScope code = new CodeWithScope("name", scope);
    String actual = writer.write(code);
    String expected = "{ \"$code\" : \"name\" , \"$scope\" : { \"firstName\" : \"Jack\" , \"lastName\" : \"Riley\" } }";
    assertSame(expected, actual);
}