diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2023-02-13 23:50:00 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2023-02-14 02:00:57 -0700 |
| commit | 06bea8e391e146b14680555fdb7c362db416da78 (patch) | |
| tree | 981d6ffcf75c546161e8ad07ff6f3b92b9c259f5 /spec | |
| parent | c03eaab75caff36a0804e932c57440289bda75d6 (diff) | |
fix test assertions to account for changes in Rouge 4.1
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/reference/source-rouge-style-with-highlighted-method-name.pdf | bin | 0 -> 19419 bytes | |||
| -rw-r--r-- | spec/source_spec.rb | 24 |
2 files changed, 18 insertions, 6 deletions
diff --git a/spec/reference/source-rouge-style-with-highlighted-method-name.pdf b/spec/reference/source-rouge-style-with-highlighted-method-name.pdf Binary files differnew file mode 100644 index 00000000..011c36ff --- /dev/null +++ b/spec/reference/source-rouge-style-with-highlighted-method-name.pdf diff --git a/spec/source_spec.rb b/spec/source_spec.rb index cdc78597..ae0cb9ce 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -225,14 +225,20 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- END + to_pdf input + + expected_file = (Gem::Version.new Rouge.version) >= (Gem::Version.new '4.1.0') ? + 'source-rouge-style-with-highlighted-method-name.pdf' : + 'source-rouge-style.pdf' + to_file = to_pdf_file input, 'source-rouge-style.pdf' - (expect to_file).to visually_match 'source-rouge-style.pdf' + (expect to_file).to visually_match expected_file to_file = to_pdf_file input, 'source-rouge-style.pdf', attribute_overrides: { 'rouge-style' => (Rouge::Theme.find 'molokai').new } - (expect to_file).to visually_match 'source-rouge-style.pdf' + (expect to_file).to visually_match expected_file to_file = to_pdf_file input, 'source-rouge-style.pdf', attribute_overrides: { 'rouge-style' => (Rouge::Theme.find 'molokai') } - (expect to_file).to visually_match 'source-rouge-style.pdf' + (expect to_file).to visually_match expected_file end it 'should disable highlighting instead of crashing if lexer fails to lex source' do @@ -294,10 +300,10 @@ describe 'Asciidoctor::PDF::Converter - Source' do end end - it 'should allow token to be formatted in bold and italic' do - pdf = to_pdf <<~'END', analyze: true + it 'should allow token to be formatted in bold, italic, and bold italic' do + pdf = to_pdf <<~'END', analyze: true, debug: true :source-highlighter: rouge - :rouge-style: github + :rouge-style: monokai [source,d] ---- @@ -306,9 +312,15 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- END + line_text = pdf.find_unique_text 'int' + (expect line_text).not_to be_empty + (expect line_text[:font_name]).to eql 'mplus1mn-bold' line_text = pdf.find_unique_text %r/^#line 6 / (expect line_text).not_to be_empty (expect line_text[:font_name]).to eql 'mplus1mn-bold_italic' + line_text = pdf.find_unique_text %r/^\/\/ this is now / + (expect line_text).not_to be_empty + (expect line_text[:font_name]).to eql 'mplus1mn-italic' end it 'should allow token to add underline style to token', visual: true do |
