コード例 #1
0
  @Test
  public void should_read_file_without_headers() {
    String content = fileContent("CONTENT");

    ContentWithVariables parsed = yamlFrontMatter.parse(content);

    assertThat(parsed.getVariables()).isEmpty();
    assertThat(parsed.getContent()).isEqualTo("CONTENT");
  }
コード例 #2
0
  @Test
  public void should_read_empty_file() {
    String content = fileContent("");

    ContentWithVariables parsed = yamlFrontMatter.parse(content);

    assertThat(parsed.getVariables()).isEmpty();
    assertThat(parsed.getContent()).isEmpty();
  }
コード例 #3
0
  @Test
  public void should_read_header_variables() {
    String content =
        fileContent("---", "layout: standard", "title: CodeStory - Devoxx Fight", "---", "CONTENT");

    ContentWithVariables parsed = yamlFrontMatter.parse(content);

    assertThat(parsed.getVariables())
        .includes(entry("layout", "standard"), entry("title", "CodeStory - Devoxx Fight"));
    assertThat(parsed.getContent()).isEqualTo("CONTENT");
  }
コード例 #4
0
  @Test
  public void should_ignore_commented_variable() {
    String content =
        fileContent(
            "---", "#layout: standard", "title: CodeStory - Devoxx Fight", "---", "CONTENT");

    ContentWithVariables parsed = yamlFrontMatter.parse(content);

    assertThat(parsed.getVariables())
        .excludes(entry("layout", "standard"))
        .excludes(entry("#layout", "standard"))
        .includes(entry("title", "CodeStory - Devoxx Fight"));
  }