diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-03-02 00:59:56 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-02 00:59:56 +0300 |
commit | 82bc6c6229b626dae74a12a56243c89aa8348cc3 (patch) | |
tree | e6e2d6c051cb48eca4f190e886f9b7864599eea6 /spec/lib/banzai/pipeline | |
parent | 6aa50165b0acc355925e271f07ef8e87291e0232 (diff) |
Add a spec for WikiPipeline
Removes the specs from GollumTagsFilter that were more like integration
tests for the pipeline than unit tests of the filter.
Diffstat (limited to 'spec/lib/banzai/pipeline')
-rw-r--r-- | spec/lib/banzai/pipeline/wiki_pipeline_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb new file mode 100644 index 00000000000..f42c11cedd4 --- /dev/null +++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb @@ -0,0 +1,53 @@ +require 'rails_helper' + +describe Banzai::Pipeline::WikiPipeline do + describe 'TableOfContents' do + it 'replaces the tag with the TableOfContentsFilter result' do + markdown = <<-MD.strip_heredoc + [[_TOC_]] + + ## Header + + Foo + MD + + result = described_class.call(markdown, project: spy, project_wiki: double) + + aggregate_failures do + expect(result[:output].text).not_to include '[[' + expect(result[:output].text).not_to include 'TOC' + expect(result[:output].to_html).to include(result[:toc]) + end + end + + it 'is case-sensitive' do + markdown = <<-MD.strip_heredoc + [[_toc_]] + + # Header 1 + + Foo + MD + + output = described_class.to_html(markdown, project: spy, project_wiki: double) + + expect(output).to include('[[<em>toc</em>]]') + end + + it 'handles an empty pipeline result' do + # No Markdown headers in this doc, so `result[:toc]` will be empty + markdown = <<-MD.strip_heredoc + [[_TOC_]] + + Foo + MD + + output = described_class.to_html(markdown, project: spy, project_wiki: double) + + aggregate_failures do + expect(output).not_to include('<ul>') + expect(output).to include('[[<em>TOC</em>]]') + end + end + end +end |