test/govspeak_images_test.rb in govspeak-6.5.4 vs test/govspeak_images_test.rb in govspeak-6.5.5
- old
+ new
@@ -1,7 +1,5 @@
-# encoding: UTF-8
-
require "test_helper"
require "govspeak_test_helper"
class GovspeakImagesTest < Minitest::Test
include GovspeakTestHelper
@@ -14,84 +12,84 @@
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
+ 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
doc = Govspeak::Document.new("[Image:another-id]")
- assert_equal %{\n}, doc.to_html
+ assert_equal %(\n), doc.to_html
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
@@ -99,21 +97,21 @@
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