diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2021-11-11 23:47:00 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2021-11-12 02:37:13 -0700 |
| commit | e51a749f734302e53c3f5042dbc9bf64e27940c8 (patch) | |
| tree | f6d13b19d8e189f636d10484bb776d39332ddf34 /test/parser_test.rb | |
| parent | 2d91304b853c88e5fdfa2a1ed4ac5e8e1153a009 (diff) | |
verify authors attribute is only parsed if different from computed value of implicit authors
Diffstat (limited to 'test/parser_test.rb')
| -rw-r--r-- | test/parser_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parser_test.rb b/test/parser_test.rb index 511be4a6..95d3bebc 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -380,6 +380,30 @@ context 'Parser' do assert_equal 'JCVD', doc.attributes['authorinitials'] end + test 'use implicit authors if value of authors attribute matches computed value' do + input = <<~'EOS' + Doc Writer; Junior Writer + :authors: Doc Writer, Junior Writer + EOS + doc = empty_document + parse_header_metadata input, doc + assert_equal 'Doc Writer, Junior Writer', doc.attributes['authors'] + assert_equal 'Doc Writer', doc.attributes['author_1'] + assert_equal 'Junior Writer', doc.attributes['author_2'] + end + + test 'replace implicit authors if value of authors attribute does not match computed value' do + input = <<~'EOS' + Doc Writer; Junior Writer + :authors: Stuart Rackham; Dan Allen + EOS + doc = empty_document + parse_header_metadata input, doc + assert_equal 'Stuart Rackham, Dan Allen', doc.attributes['authors'] + assert_equal 'Stuart Rackham', doc.attributes['author_1'] + assert_equal 'Dan Allen', doc.attributes['author_2'] + end + test 'sets authorcount to 0 if document has no authors' do input = '' doc = empty_document |
