Add command RENDER_FOOTNOTES_JSON
This commit is contained in:
parent
4f5feacb12
commit
9ad17cd9e5
3 changed files with 56 additions and 0 deletions
|
@ -44,6 +44,8 @@ module Referator
|
|||
config.formats.render_footnotes format, notes
|
||||
end
|
||||
|
||||
def render_footnotes_json = JSON.dump(notes).freeze
|
||||
|
||||
private
|
||||
|
||||
def config=(config)
|
||||
|
|
|
@ -129,6 +129,11 @@ module Referator
|
|||
String @footnotes.render_footnotes command.data
|
||||
end
|
||||
|
||||
def do_render_footnotes_json(_command)
|
||||
@config.freeze
|
||||
@footnotes.render_footnotes_json
|
||||
end
|
||||
|
||||
#########
|
||||
# Utils #
|
||||
#########
|
||||
|
|
49
test.rb
49
test.rb
|
@ -270,6 +270,55 @@ cmd :RENDER_FOOTNOTES, :json do |result|
|
|||
raise unless result == expected
|
||||
end
|
||||
|
||||
#########################
|
||||
# RENDER_FOOTNOTES_JSON #
|
||||
#########################
|
||||
|
||||
cmd :RENDER_FOOTNOTES_JSON do |result|
|
||||
expected = <<~JSON
|
||||
{
|
||||
"self": [
|
||||
{
|
||||
"index": 1,
|
||||
"category": "self",
|
||||
"id": "/blog/foo",
|
||||
"slug": "blog-foo",
|
||||
"url": null,
|
||||
"text": "Foo"
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"category": "self",
|
||||
"id": "/blog/bar",
|
||||
"slug": "blog-bar",
|
||||
"url": null,
|
||||
"text": "Bar"
|
||||
}
|
||||
],
|
||||
"link": [
|
||||
{
|
||||
"index": 3,
|
||||
"category": "link",
|
||||
"id": "example_com",
|
||||
"slug": "example-com",
|
||||
"url": "https://example.com",
|
||||
"text": "Example Domain"
|
||||
},
|
||||
{
|
||||
"index": 4,
|
||||
"category": "link",
|
||||
"id": "causa_arcana_com",
|
||||
"slug": "causa-arcana-com",
|
||||
"url": "https://causa-arcana.com",
|
||||
"text": "Causa Arcana"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
raise unless JSON.parse(result) == JSON.parse(expected)
|
||||
end
|
||||
|
||||
########
|
||||
# EXIT #
|
||||
########
|
||||
|
|
Loading…
Reference in a new issue