1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Merge pull request #1851 from terceiro/test-haml-6

Tests against Haml 6
This commit is contained in:
Jordan Owens 2022-12-24 10:31:43 -05:00 committed by GitHub
commit 69ad250ed3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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