Sha256: dff9a1cd7dd65ced873010cb0de1777a4eb58a88c1370c6b140a381d8988ed49

Contents?: true

Size: 792 Bytes

Versions: 8

Compression:

Stored size: 792 Bytes

Contents

require 'spec_helper'

RSpec.describe 'Plain rendering', type: :render do
  it 'outputs literally when prefixed with "\\"' do
    expect(render_string('\= @title')).to eq("= @title\n")
  end

  it 'correctly escapes interpolation' do
    expect(render_string(<<'HAML')).to eq("<span>foo\\3bar</span>\n")
%span foo\\#{1 + 2}bar
HAML
    expect(render_string(<<'HAML')).to eq("<span>foo\\\#{1 + 2}bar</span>\n")
%span foo\\\#{1 + 2}bar
HAML
  end

  it 'raises error when interpolation is unterminated' do
    expect { render_string('%span foo#{1 + 2') }.to raise_error(Faml::TextCompiler::InvalidInterpolation)
  end

  it 'raises error when text has children' do
    expect { render_string(<<HAML) }.to raise_error(Faml::SyntaxError, /nesting within plain text/)
hello
  world
HAML
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
faml-0.2.16 spec/render/plain_spec.rb
faml-0.2.15 spec/render/plain_spec.rb
faml-0.2.14 spec/render/plain_spec.rb
faml-0.2.13 spec/render/plain_spec.rb
faml-0.2.12 spec/render/plain_spec.rb
faml-0.2.11 spec/render/plain_spec.rb
faml-0.2.10 spec/render/plain_spec.rb
faml-0.2.9 spec/render/plain_spec.rb