require 'rails_helper'
describe BaseMarkdownRenderer do
  let(:renderer) { described_class.new }
  def render_markdown(markdown)
    doc = CommonMarker.render_doc(markdown, :DEFAULT)
    renderer.render(doc)
  end
  describe '#image' do
    context 'when image has a height' do
      it 'renders the img tag with the correct attributes' do
        markdown = ''
        expect(render_markdown(markdown)).to include('
')
      end
    end
    context 'when image does not have a height' do
      it 'renders the img tag without the height attribute' do
        markdown = ''
        expect(render_markdown(markdown)).to include('
')
      end
    end
    context 'when image has an invalid URL' do
      it 'renders the img tag without crashing' do
        markdown = ''
        expect { render_markdown(markdown) }.not_to raise_error
      end
    end
  end
end