2020-10-27 17:08:45 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Banzai::Pipeline::PreProcessPipeline do
|
|
|
|
it 'pre-processes the source text' do
|
|
|
|
markdown = <<~MD
|
|
|
|
\xEF\xBB\xBF---
|
|
|
|
foo: :foo_symbol
|
|
|
|
bar: :bar_symbol
|
|
|
|
---
|
|
|
|
|
|
|
|
>>>
|
|
|
|
blockquote
|
|
|
|
>>>
|
|
|
|
MD
|
|
|
|
|
|
|
|
result = described_class.call(markdown, {})
|
|
|
|
|
|
|
|
aggregate_failures do
|
|
|
|
expect(result[:output]).not_to include "\xEF\xBB\xBF"
|
|
|
|
expect(result[:output]).not_to include '---'
|
2021-09-23 08:11:29 -04:00
|
|
|
expect(result[:output]).to include "```yaml:frontmatter\nfoo: :foo_symbol\n"
|
2020-10-27 17:08:45 -04:00
|
|
|
expect(result[:output]).to include "> blockquote\n"
|
|
|
|
end
|
|
|
|
end
|
2021-01-19 04:10:32 -05:00
|
|
|
|
|
|
|
it 'truncates the text if requested' do
|
|
|
|
text = (['foo'] * 10).join(' ')
|
|
|
|
|
|
|
|
result = described_class.call(text, limit: 12)
|
|
|
|
|
2021-02-01 04:09:28 -05:00
|
|
|
expect(result[:output]).to eq('foo foo f...')
|
2021-01-19 04:10:32 -05:00
|
|
|
end
|
2020-10-27 17:08:45 -04:00
|
|
|
end
|