Sha256: 88dfd11f5c34637dbc9c9f46e686cfd71c3d82da6fa61841b534279a368fb0ec

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

# frozen-string-literal: true
require 'spec_helper'

RSpec.describe 'Sanitize rendering', type: :render do
  it 'parses sanitized script' do
    # Default in faml
    expect(render_string('&= "hello<p>unescape</p>world"')).to eq("hello&lt;p&gt;unescape&lt;/p&gt;world\n")
    expect(render_string(<<HAML)).to eq("<span>\nhello&lt;p&gt;unescape&lt;/p&gt;world\n</span>\n")
%span
  &= "hello<p>unescape</p>world"
HAML
  end

  it 'ignores single sanitize 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 'parses == syntax' 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

  context 'with preserve' do
    it 'ignores preserve mark' do
      expect(render_string('&~ "<p>hello</p>"')).to eq("&lt;p&gt;hello&lt;/p&gt;\n")
      expect(render_string('%span&~ "<p>hello</p>"')).to eq("<span>&lt;p&gt;hello&lt;/p&gt;</span>\n")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
faml-0.7.3 spec/render/sanitize_spec.rb
faml-0.7.2 spec/render/sanitize_spec.rb
faml-0.7.1 spec/render/sanitize_spec.rb
faml-0.7.0 spec/render/sanitize_spec.rb
faml-0.6.5 spec/render/sanitize_spec.rb
faml-0.6.4 spec/render/sanitize_spec.rb
faml-0.6.3 spec/render/sanitize_spec.rb
faml-0.6.2 spec/render/sanitize_spec.rb
faml-0.6.1 spec/render/sanitize_spec.rb