Tests against Haml 6

In Haml 6, = escapes the results of the Ruby expression by default. If
you want that to be a nested  template it needs to be called with !=.

Also, attr_wrapper is no longer a valid option.
This commit is contained in:
Antonio Terceiro 2022-12-23 22:57:59 -03:00
parent 2ccd0dc29d
commit c5b8872473
2 changed files with 6 additions and 6 deletions

View File

@ -38,7 +38,7 @@ gem 'commonmarker', '~> 0.23.4', platforms: [:ruby]
gem 'erubi' gem 'erubi'
gem 'eventmachine' gem 'eventmachine'
gem 'falcon', '~> 0.40', platforms: [:ruby] gem 'falcon', '~> 0.40', platforms: [:ruby]
gem 'haml', '~> 5' gem 'haml', '~> 6'
gem 'kramdown' gem 'kramdown'
gem 'liquid' gem 'liquid'
gem 'markaby' gem 'markaby'

View File

@ -26,7 +26,7 @@ class HAMLTest < Minitest::Test
it "renders with inline layouts" do it "renders with inline layouts" do
mock_app do mock_app do
layout { %q(%h1= 'THIS. IS. ' + yield.upcase) } layout { %q(%h1!= 'THIS. IS. ' + yield.upcase) }
get('/') { haml '%em Sparta' } get('/') { haml '%em Sparta' }
end end
get '/' get '/'
@ -66,7 +66,7 @@ class HAMLTest < Minitest::Test
it "merges the default HAML options with the overrides and passes them to the Haml engine" do it "merges the default HAML options with the overrides and passes them to the Haml engine" do
mock_app do mock_app do
set :haml, {:format => :html5, :attr_wrapper => '"'} # default HAML attr are <tag attr='single-quoted'> set :haml, {:format => :html5}
get('/') { haml "!!!\n%h1{:class => :header} Hello World" } get('/') { haml "!!!\n%h1{:class => :header} Hello World" }
get('/html4') { get('/html4') {
haml "!!!\n%h1{:class => 'header'} Hello World", :format => :html4 haml "!!!\n%h1{:class => 'header'} Hello World", :format => :html4
@ -74,7 +74,7 @@ class HAMLTest < Minitest::Test
end end
get '/' get '/'
assert ok? assert ok?
assert_equal "<!DOCTYPE html>\n<h1 class=\"header\">Hello World</h1>\n", body assert_equal "<!DOCTYPE html>\n<h1 class='header'>Hello World</h1>\n", body
get '/html4' get '/html4'
assert ok? assert ok?
assert_match(/^<!DOCTYPE html PUBLIC (.*) HTML 4.01/, body) assert_match(/^<!DOCTYPE html PUBLIC (.*) HTML 4.01/, body)
@ -87,8 +87,8 @@ class HAMLTest < Minitest::Test
it "can render truly nested layouts by accepting a layout and a block with the contents" do it "can render truly nested layouts by accepting a layout and a block with the contents" do
mock_app do mock_app do
template(:main_outer_layout) { "%h1 Title\n= yield" } template(:main_outer_layout) { "%h1 Title\n!= yield" }
template(:an_inner_layout) { "%h2 Subtitle\n= yield" } template(:an_inner_layout) { "%h2 Subtitle\n!= yield" }
template(:a_page) { "%p Contents." } template(:a_page) { "%p Contents." }
get('/') do get('/') do
haml :main_outer_layout, :layout => false do haml :main_outer_layout, :layout => false do