Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions test/perron/resource/separator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,46 @@ def test_handles_empty_frontmatter
assert_equal "Content with empty frontmatter", separator.content
assert_empty separator.frontmatter.to_h
end

def test_parses_inline_array_syntax
content = <<~CONTENT
---
authors: [alice, bob]
---
Content
CONTENT
separator = Perron::Resource::Separator.new(content)
assert_equal ["alice", "bob"], separator.frontmatter.authors
end

def test_parses_yaml_list_syntax
content = <<~CONTENT
---
authors:
- alice
- bob
---
Content
CONTENT
separator = Perron::Resource::Separator.new(content)
assert_equal ["alice", "bob"], separator.frontmatter.authors
end

def test_parses_mixed_types_in_frontmatter
content = <<~CONTENT
---
title: Hello
tags: [ruby, yaml]
categories:
- tech
- tutorial
---
Content
CONTENT
separator = Perron::Resource::Separator.new(content)

assert_equal "Hello", separator.frontmatter.title
assert_equal ["ruby", "yaml"], separator.frontmatter.tags
assert_equal ["tech", "tutorial"], separator.frontmatter.categories
end
end
Loading