summaryrefslogtreecommitdiff
path: root/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-03-01 16:59:56 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-03-01 16:59:56 -0500
commit82bc6c6229b626dae74a12a56243c89aa8348cc3 (patch)
treee6e2d6c051cb48eca4f190e886f9b7864599eea6 /spec/lib/banzai/filter/gollum_tags_filter_spec.rb
parent6aa50165b0acc355925e271f07ef8e87291e0232 (diff)
downloadgitlab-ce-82bc6c6229b626dae74a12a56243c89aa8348cc3.tar.gz
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/filter/gollum_tags_filter_spec.rb')
-rw-r--r--spec/lib/banzai/filter/gollum_tags_filter_spec.rb51
1 files changed, 7 insertions, 44 deletions
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
index 11cc290d6d0..8c71889caf0 100644
--- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
+++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
@@ -88,54 +88,17 @@ describe Banzai::Filter::GollumTagsFilter, lib: true do
end
context 'table of contents' do
- let(:pipeline) { Banzai::Pipeline[:wiki] }
+ it 'replaces [[<em>TOC</em>]] with ToC result' do
+ doc = described_class.call("<p>[[<em>TOC</em>]]</p>", { project_wiki: project_wiki }, { toc: "FOO" })
- it 'replaces the tag with the TableOfContentsFilter result' do
- markdown = <<-MD.strip_heredoc
- [[_TOC_]]
-
- ## Header
-
- Foo
- MD
-
- result = pipeline.call(markdown, project_wiki: project_wiki, project: project)
-
- aggregate_failures do
- expect(result[:output].text).not_to include '[[_TOC_]]'
- expect(result[:output].text).not_to include '[['
- 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 = pipeline.to_html(markdown, project_wiki: project_wiki, project: project)
-
- expect(output).to include('[[<em>toc</em>]]')
+ expect(doc.to_html).to eq("FOO")
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 = pipeline.to_html(markdown, project_wiki: project_wiki, project: project)
+ it 'handles an empty ToC result' do
+ input = output = "<p>[[<em>TOC</em>]]</p>"
+ doc = described_class.call(input, project_wiki: project_wiki)
- aggregate_failures do
- expect(output).not_to include('<ul>')
- expect(output).to include('[[<em>TOC</em>]]')
- end
+ expect(doc.to_html).to eq output
end
end
end