require 'forwardable'
using Corefines::String::unindent
module DocTest
describe HTML::Converter do
extend Forwardable
def_delegator :converter, :convert_examples
subject(:converter) { described_class.new }
describe '#convert_examples' do
let(:input) { Example.new 's:dummy', content: '*chunky* bacon', opts: input_opts }
let(:input_opts) { {} }
let(:output) { Example.new 's:dummy', content: output_content, opts: output_opts }
let(:output_content) { 'chunky bacon' }
let(:output_opts) { {dummy: 'value'} }
let(:converter_opts) { {header_footer: false} }
subject(:result) { convert_examples input, output }
let :rendered do
<<-EOF
Chunky baconTitle
meh
why?
Chunkybacon
why?
' end end context 'with :header_footer option' do let(:converter_opts) { {header_footer: true} } context 'specified in output example' do let(:output_opts) { {header_footer: true} } it 'renders content with :header_footer => true' do convert_examples input, output end end context 'specified in input example' do let(:input_opts) { {header_footer: true} } it 'renders content with :header_footer => true' do convert_examples input, output end context 'and disabled in output example' do let(:output_opts) { {header_footer: false} } let(:converter_opts) { {header_footer: false} } it 'renders content with :header_footer => false' do convert_examples input, output end end end end context 'with example named /^document.*/' do let(:input) { Example.new 'document:dummy', content: '*chunky* bacon' } let(:converter_opts) { {header_footer: true} } it 'renders content with :header_footer => true' do convert_examples input, output end end context 'with example named /inline_.*/' do let(:input) { Example.new 'inline_quoted:dummy', content: '*chunky* bacon' } let(:rendered) { 'chunky bacon
' } it 'returns content without top-leveltags' do expect(result.first).to eq 'chunky bacon' end context 'with :include option' do let(:output_opts) { {include: ['.//b']} } it 'preferes the include option' do expect(result.first).to eq 'chunky' end end end context 'with output example including DOCTYPE' do let :output_content do <<-EOF.unindent.strip