require 'forwardable' 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' } let(:output) { Example.new 's:dummy', content: 'chunky bacon', opts: opts } let(:opts) { {dummy: 'value'} } let(:converter_opts) { {header_footer: false} } subject(:result) { convert_examples input, output } let :rendered do <<-EOF

Title

Chunky bacon

meh

why?

EOF end before do expect(converter).to receive(:convert) .with(input.content, converter_opts).and_return(rendered) end it 'returns array of converted input content and output content' context 'with :exclude option' do let(:opts) { {exclude: ['.//p', './/code']} } it 'returns content without HTML (sub)elements specified by XPath' do expect(result.first.gsub(/\s*/, '')).to eq \ '

Title

' end end context 'with :include option' do let(:opts) { {include: ['.//p']} } it 'returns content with only HTML (sub)elements specified by XPath' do expect(result.first.gsub(/\s*/, '')).to eq '

Chunkybacon

why?

' end end context 'with :header_footer option' do let(:opts) { {header_footer: true} } let(:converter_opts) { {header_footer: true} } it 'renders content with :header_footer => true' do convert_examples input, output 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-level

tags' do expect(result.first).to eq 'chunky bacon' end context 'with :include option' do let(:opts) { {include: ['.//b']} } it 'preferes the include option' do expect(result.first).to eq 'chunky' end end end end end end