require 'spec_helper' require 'tempfile' module RevealCK module Markdown describe SlideMarkdownTemplate do def render_markdown(markdown) tmp_file = Tempfile.new(['test', '.md']) File.open(tmp_file, 'w') do |test_md| test_md.puts(markdown) end template = Tilt.new(tmp_file.path) template.render end it 'does not turn _s within a single emoji into s' do output = render_markdown <<-SLIDES.strip_heredoc :money_with_wings: SLIDES expect(output).to include ':money_with_wings:' end it 'does not turn _s between two emojis into s' do output = render_markdown <<-SLIDES.strip_heredoc :blue_heart: :blue_heart: SLIDES expect(output).to include ':blue_heart: :blue_heart:' end it 'uses "---" to create "
"s' do output = render_markdown <<-SLIDES.strip_heredoc # h1 Slide --- ## h2 Slide SLIDES expect(output).to include '

h1 Slide

' expect(output).to include "
\n
" expect(output).to include '

h2 Slide

' end it 'wraps ``` code in a
 and ' do
        output = render_markdown <<-SLIDES.strip_heredoc
        ```
        def adder(a, b); a + b; end
        ```
        SLIDES
        expect(output).to include '
'
        expect(output).to include '
' expect(output).to include 'a + b' end it 'converts special characters in ``` block to entity references' do output = render_markdown <<-SLIDES.strip_heredoc ```

"&"

``` SLIDES expect(output).to include '
'
        expect(output).to include '
' expect(output).to include '<p>"&"</p>' end it 'wraps ```ruby code in a
 and ' do
        output = render_markdown <<-SLIDES.strip_heredoc
        ```ruby
        def adder(a, b); a + b; end
        ```
        SLIDES
        expect(output).to include '
'
        expect(output).to include '
' expect(output).to include 'a + b' end it 'works when there is no space surrounding the ---' do output = render_markdown <<-SLIDES.strip_heredoc # Your headline * Bullet 1 * Bullet 2 --- # Next Slide SLIDES expect(output).to include "
\n
" end end end end