1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
Description: Update tests for Haml v7
Author: Patrik Ragnarsson <patrik@starkast.net>
Origin: upstream
Applied-Upstream: 0135c85402f08e8a82dc3d270d9ba5a87b13aa40
Reviewed-by: Simon Quigley <tsimonq2@debian.org>
Last-Update: 2026-02-22
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/sinatra-contrib/spec/haml_helpers_spec.rb
+++ b/sinatra-contrib/spec/haml_helpers_spec.rb
@@ -3,6 +3,8 @@ require 'spec_helper'
require 'sinatra/haml_helpers'
RSpec.describe Sinatra::HamlHelpers do
+ let(:quote_char) { Haml::VERSION >= "7.0.0" ? "\"" : "'" }
+
describe "#surround" do
it "renders correctly" do
mock_app do
@@ -20,7 +22,7 @@ RSpec.describe Sinatra::HamlHelpers do
get "/"
html_code = <<~HTML
<p>
- (<a href='https://example.org/'>surrounded</a>)
+ (<a href=#{quote_char}https://example.org/#{quote_char}>surrounded</a>)
</p>
HTML
expect(body).to eq(html_code)
@@ -44,7 +46,7 @@ RSpec.describe Sinatra::HamlHelpers do
get "/"
html_code = <<~HTML
<p>
- * <a href='https://example.org/'>preceded</a>
+ * <a href=#{quote_char}https://example.org/#{quote_char}>preceded</a>
</p>
HTML
expect(body).to eq(html_code)
@@ -68,7 +70,7 @@ RSpec.describe Sinatra::HamlHelpers do
get "/"
html_code = <<~HTML
<p>
- <a href='https://example.org/'>succeeded</a>.
+ <a href=#{quote_char}https://example.org/#{quote_char}>succeeded</a>.
</p>
HTML
expect(body).to eq(html_code)
--- a/test/haml_test.rb
+++ b/test/haml_test.rb
@@ -65,6 +65,7 @@ class HAMLTest < Minitest::Test
end
it "merges the default HAML options with the overrides and passes them to the Haml engine" do
+ quote_char = Haml::VERSION >= "7.0.0" ? "\"" : "'"
mock_app do
set :haml, {:format => :html5}
get('/') { haml "!!!\n%h1{:class => :header} Hello World" }
@@ -74,7 +75,7 @@ class HAMLTest < Minitest::Test
end
get '/'
assert ok?
- assert_equal "<!DOCTYPE html>\n<h1 class='header'>Hello World</h1>\n", body
+ assert_equal "<!DOCTYPE html>\n<h1 class=#{quote_char}header#{quote_char}>Hello World</h1>\n", body
get '/html4'
assert ok?
assert_match(/^<!DOCTYPE html PUBLIC (.*) HTML 4.01/, body)
|