test/govspeak_images_test.rb in govspeak-6.7.1 vs test/govspeak_images_test.rb in govspeak-6.7.2
- old
+ new
@@ -12,23 +12,19 @@
end
test "Image:image-id syntax renders an image in options[:images]" do
given_govspeak "[Image:image-id]", images: [build_image] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>",
)
end
end
test "Image:image-id syntax escapes alt text" do
given_govspeak "[Image:image-id]", images: [build_image(alt_text: %(my alt '&"<>))] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&"<>"></div>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt '&"<>\"></div></figure>",
)
end
end
test "Image:image-id syntax renders nothing if not found" do
@@ -37,59 +33,43 @@
end
test "Image:image-id syntax adds image caption if given" do
given_govspeak "[Image:image-id]", images: [build_image(caption: "My Caption & so on")] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
- %(<figcaption><p>My Caption & so on</p></figcaption>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div>\n<figcaption><p>My Caption & so on</p></figcaption></figure>",
)
end
end
test "Image:image-id syntax ignores a blank caption" do
given_govspeak "[Image:image-id]", images: [build_image(caption: " ")] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>",
)
end
end
test "Image:image-id syntax adds image credit if given" do
given_govspeak "[Image:image-id]", images: [build_image(credit: "My Credit & so on")] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
- %(<figcaption><p>Image credit: My Credit & so on</p></figcaption>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div>\n<figcaption><p>Image credit: My Credit & so on</p></figcaption></figure>",
)
end
end
test "Image:image-id syntax ignores a blank credit" do
given_govspeak "[Image:image-id]", images: [build_image(credit: " ")] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>",
)
end
end
test "Image:image-id syntax adds image caption and credit if given" do
given_govspeak "[Image:image-id]", images: [build_image(caption: "My Caption & so on", credit: "My Credit & so on")] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
- %(<figcaption>) +
- %(<p>My Caption & so on</p>\n) +
- %(<p>Image credit: My Credit & so on</p>) +
- %(</figcaption>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div>\n<figcaption><p>My Caption & so on</p>\n<p>Image credit: My Credit & so on</p></figcaption></figure>",
)
end
end
test "Image is not inserted when it does not start on a new line" do
@@ -97,21 +77,16 @@
assert_html_output("<p>some text [Image:image-id]</p>")
end
given_govspeak "[Image:image-id]", images: [build_image] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
- %(</figure>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>",
)
end
given_govspeak "[Image:image-id] some text", images: [build_image] do
assert_html_output(
- %(<figure class="image embedded">) +
- %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
- %(</figure>\n) +
- %(<p>some text</p>),
+ "<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>\n<p>some text</p>",
)
end
end
end