diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2020-02-10 03:30:20 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2020-02-10 03:30:20 -0700 |
| commit | 669b425460ff7e3a47bdd4567ed6bcc0039bc047 (patch) | |
| tree | c4a8c9e962930fc8d46efb87c247d60f967cc96c | |
| parent | a6e23a6d70ade0b7a3b2a7a54054229b78c4780e (diff) | |
verify warning is logged if variable reference in theme cannot be resolved
| -rw-r--r-- | spec/theme_loader_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/theme_loader_spec.rb b/spec/theme_loader_spec.rb index 604a71fa..b9e1a3ee 100644 --- a/spec/theme_loader_spec.rb +++ b/spec/theme_loader_spec.rb @@ -592,6 +592,19 @@ describe Asciidoctor::PDF::ThemeLoader do (expect theme.heading_font_color).to eql theme.base_font_color end + it 'should warn if variable reference cannot be resolved' do + (expect do + theme_data = SafeYAML.load <<~EOS + brand: + blue: '0000FF' + base: + font_color: $brand-red + EOS + theme = subject.new.load theme_data + (expect theme.base_font_color).to eql '$BRAND' + end).to log_message severity: :WARN, message: %(unknown variable reference in PDF theme: $brand-red) + end + it 'should interpolate variables in value' do theme_data = SafeYAML.load <<~EOS brand: @@ -607,6 +620,19 @@ describe Asciidoctor::PDF::ThemeLoader do (expect theme.heading_font_family).to eql 'Noto Sans' end + it 'should warn if variable reference cannot be resolved when interpolating value' do + (expect do + theme_data = SafeYAML.load <<~EOS + brand: + font_family_name: Noto + base: + font_family: $brand-font-family-name $brand-font-family-variant + EOS + theme = subject.new.load theme_data + (expect theme.base_font_family).to eql 'Noto $brand-font-family-variant' + end).to log_message severity: :WARN, message: %(unknown variable reference in PDF theme: $brand-font-family-variant) + end + it 'should interpolate computed value' do theme_data = SafeYAML.load <<~EOS base: |
