require 'spec_helper' RSpec.describe 'Script rendering', type: :render do it 'parses script' do expect(render_string('%span= 1 + 2')).to eq("3\n") end it 'parses multi-line script' do expect(render_string(<\n3\n\n") %span = 1 + 2 HAML end it 'parses script and text' do expect(render_string(<\n3\n3\n9\n\n") %span = 1 + 2 3 = 4 + 5 HAML end it 'can contain Ruby comment' do expect(render_string('%span= 1 + 2 # comments')).to eq("3\n") end it 'can contain Ruby comment in multi-line' do expect(render_string(<\n3\n3\n9\n\n") %span = 1 + 2 # comment 3 = 4 + 5 # comment HAML end it 'can be comment-only' do expect(render_string(<0\n1end\n") = 1.times do |i| %span= i %span end HAML end it 'escapes unsafe string' do expect(render_string(<<script>alert(1)</script>

\n") - title = '' %p= title HAML end it 'parses Ruby multiline' do expect(render_string(<\n\n2+3i\n\n\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(<