Sha256: de42886a7cdc54753b5e6d290c26fd25ea1ded0cfee6a9936d5e42d239b5f889
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# encoding: UTF-8 require 'test_helper' require 'govspeak_test_helper' class GovspeakImagesTest < Minitest::Test include GovspeakTestHelper def build_image(attrs = {}) attrs[:alt_text] ||= "my alt" attrs[:url] ||= "http://example.com/image.jpg" attrs[:id] ||= "image-id" attrs 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>} ) 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>} ) 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 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>My Caption & so on</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>} ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
govspeak-5.8.0 | test/govspeak_images_test.rb |