Skip to content
Permalink
Browse files

Refactor Rouge tests to specs

  • Loading branch information...
barraq committed Oct 25, 2016
1 parent 3d1c223 commit af37a8cf13e2d5af7e09c093ad37882407416a02
Showing with 118 additions and 117 deletions.
  1. +118 −0 spec/nanoc/filters/colorize_syntax/rouge_spec.rb
  2. +0 −117 test/filters/colorize_syntax/test_rouge.rb
@@ -0,0 +1,118 @@
require 'rouge'

describe Nanoc::Filters::ColorizeSyntax, filter: true do
subject { filter.setup_and_run(input, default_colorizer: :rouge, rouge: params) }
let(:filter) { ::Nanoc::Filters::ColorizeSyntax.new }
let(:params) { {} }
let(:wrap) { false }
let(:css_class) { 'highlight' }
let(:input) do
<<-EOS.freeze
before
<pre><code class="language-ruby">
def foo
end
</code></pre>
after
EOS
end
let(:output) do
<<-EOS
before
<pre><code class=\"language-ruby#{wrap ? " #{css_class}" : ''}\"> <span class=\"k\">def</span> <span class=\"nf\">foo</span>
<span class=\"k\">end</span></code></pre>
after
EOS
end

context 'with Rouge' do
context 'with 1.x', if: Rouge.version < '2' do
context 'with default options' do
it { is_expected.to eql output }
end

context 'with pygments wrapper' do
let(:wrap) { true }
let(:params) { super().merge({ wrap: wrap }) }

it { is_expected.to eql output }

context 'with css_class' do
let(:css_class) { 'nanoc' }
let(:params) { super().merge({ css_class: css_class }) }

it { is_expected.to eql output }
end
end

context 'with line number' do
let(:line_numbers) { true }
let(:params) { super().merge({ line_numbers: line_numbers }) }
let(:output) do
<<-EOS
before
<pre><code class="language-ruby"><table style="border-spacing: 0"><tbody><tr>
<td class="gutter gl" style="text-align: right"><pre class="lineno">1
2</pre></td>
<td class="code"><pre> <span class="k">def</span> <span class="nf">foo</span>
<span class="k">end</span><span class="w">
</span></pre></td>
</tr></tbody></table></code></pre>
after
EOS
end

it { is_expected.to eql output }
end
end

context 'with 2.x', if: Rouge.version >= '2' do
subject { filter.setup_and_run(input, default_colorizer: :rouge, rouge: params) }

context 'with default options' do
it { is_expected.to eql output }
end

context 'with legacy' do
let(:legacy) { true }
let(:params) { super().merge({ legacy: legacy }) }

it { is_expected.to eql output }

context 'with pygments wrapper' do
let(:wrap) { true }
let(:params) { super().merge({ wrap: wrap }) }

it { is_expected.to eql output }

context 'with css_class' do
let(:css_class) { 'nanoc' }
let(:params) { super().merge({ css_class: css_class }) }

it { is_expected.to eql output }
end
end

context 'with line number' do
let(:line_numbers) { true }
let(:params) { super().merge({ line_numbers: line_numbers }) }
let(:output) do
<<-EOS
before
<pre><code class="language-ruby"><table class="rouge-table"><tbody><tr>
<td class="rouge-gutter gl"><pre class="lineno">1
2
</pre></td>
<td class="rouge-code"><pre> <span class="k">def</span> <span class="nf">foo</span>
<span class="k">end</span></pre></td>
</tr></tbody></table></code></pre>
after
EOS
end

it { is_expected.to eql output }
end
end
end
end
end

This file was deleted.

Oops, something went wrong.

0 comments on commit af37a8c

Please sign in to comment.
You can’t perform that action at this time.