Sha256: 8e9d472156613f7d89246f396a473e90a7cbc94f3b5b6519ca84467dd5bb169f
Contents?: true
Size: 1.66 KB
Versions: 17
Compression:
Stored size: 1.66 KB
Contents
require 'spec_helper' RSpec.describe 'Script rendering', type: :render do it 'parses script' do expect(render_string('%span= 1 + 2')).to eq("<span>3</span>\n") end it 'parses multi-line script' do expect(render_string(<<HAML)).to eq("<span>\n3\n</span>\n") %span = 1 + 2 HAML end it 'parses script and text' do expect(render_string(<<HAML)).to eq("<span>\n3\n3\n9\n</span>\n") %span = 1 + 2 3 = 4 + 5 HAML end it 'can contain Ruby comment' do expect(render_string('%span= 1 + 2 # comments')).to eq("<span>3</span>\n") end it 'can contain Ruby comment in multi-line' do expect(render_string(<<HAML)).to eq("<span>\n3\n3\n9\n</span>\n") %span = 1 + 2 # comment 3 = 4 + 5 # comment HAML end it 'can be comment-only' do expect(render_string(<<HAML)).to eq("\nstring\n") = # comment = 'string' HAML end it 'can have children' do expect(render_string(<<HAML)).to eq("<span>0</span>\n1<span>end</span>\n") = 1.times do |i| %span= i %span end HAML end it 'escapes unsafe string' do expect(render_string(<<HAML)).to eq("<p><script>alert(1)</script></p>\n") - title = '<script>alert(1)</script>' %p= title HAML end it 'parses Ruby multiline' do expect(render_string(<<HAML)).to eq("<div>\n<span>\n2+3i\n</span>\n</div>\n") %div %span = Complex(2, 3) HAML end it 'parses == syntax' do expect(render_string('== =#{1+2}hello')).to eq("=3hello\n") end context 'without Ruby code' do it 'raises error' do expect { render_string('%span=') }.to raise_error(Faml::SyntaxError) expect { render_string(<<HAML) }.to raise_error(Faml::SyntaxError) %span = HAML end end end
Version data entries
17 entries across 17 versions & 1 rubygems