Sha256: d459c48213e1c34d6c3bc65224972b3d904afab37ce8fd61990e8edf962db285

Contents?: true

Size: 1.79 KB

Versions: 17

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

RSpec.describe 'Unescape rendering', type: :render do
  it 'parses unescape script' do
    expect(render_string('%span!= "hello<p>unescape</p>world"')).to eq("<span>hello<p>unescape</p>world</span>\n")
    expect(render_string(<<HAML)).to eq("<span>\nhello<p>unescape</p>world\n</span>\n")
%span
  != "hello<p>unescape</p>world"
HAML
  end

  it 'ignores single unescape mark' do
    expect(render_string('! <p>hello</p>')).to eq("<p>hello</p>\n")
    expect(render_string('%span! <p>hello</p>')).to eq("<span><p>hello</p></span>\n")
  end

  it 'ignores single Unescape mark without spaces' do
    expect(render_string('!<p>hello</p>')).to eq("<p>hello</p>\n")
    expect(render_string('%span!<p>hello</p>')).to eq("<span><p>hello</p></span>\n")
  end

  it 'has effect on string interpolation in plain' do
    expect(render_string('! <p>#{"<strong>hello</strong>"}</p>')).to eq("<p><strong>hello</strong></p>\n")
    expect(render_string('%span! <p>#{"<strong>hello</strong>"}</p>')).to eq("<span><p><strong>hello</strong></p></span>\n")
  end

  it 'parses == syntax' do
    expect(render_string('!== =#{"<br>"}hello')).to eq("=<br>hello\n")
    expect(render_string('%p!== =#{"<br>"}hello')).to eq("<p>=<br>hello</p>\n")
  end

  context 'with preserve' do
    it 'keeps newlines within preserve tags' do
      expect(render_string('!~ "<p>hello\n<pre>pre\nworld</pre></p>"')).to eq("<p>hello\n<pre>pre&#x000A;world</pre></p>\n")
      expect(render_string('%span!~ "<p>hello\n<pre>pre\nworld</pre></p>"')).to eq("<span><p>hello\n<pre>pre&#x000A;world</pre></p></span>\n")
    end
  end

  context 'without Ruby code' do
    it 'raises error' do
      expect { render_string('%span!=') }.to raise_error(Faml::SyntaxError)
      expect { render_string('!=') }.to raise_error(Faml::SyntaxError)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
faml-0.2.16 spec/render/unescape_spec.rb
faml-0.2.15 spec/render/unescape_spec.rb
faml-0.2.14 spec/render/unescape_spec.rb
faml-0.2.13 spec/render/unescape_spec.rb
faml-0.2.12 spec/render/unescape_spec.rb
faml-0.2.11 spec/render/unescape_spec.rb
faml-0.2.10 spec/render/unescape_spec.rb
faml-0.2.9 spec/render/unescape_spec.rb
faml-0.2.8 spec/render/unescape_spec.rb
faml-0.2.7 spec/render/unescape_spec.rb
faml-0.2.6 spec/render/unescape_spec.rb
faml-0.2.5 spec/render/unescape_spec.rb
faml-0.2.4 spec/render/unescape_spec.rb
faml-0.2.3 spec/render/unescape_spec.rb
faml-0.2.2 spec/render/unescape_spec.rb
faml-0.2.1 spec/render/unescape_spec.rb
faml-0.2.0 spec/render/unescape_spec.rb