govspeak 6.5.4 → 6.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
 
5
3
  class GovspeakAttachmentLinkTest < Minitest::Test
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
 
5
3
  class GovspeakAttachmentTest < Minitest::Test
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
 
5
3
  class GovspeakAttachmentsImageTest < Minitest::Test
@@ -77,11 +75,11 @@ class GovspeakAttachmentsImageTest < Minitest::Test
77
75
  "[embed:attachments:image:1fe8]",
78
76
  [build_attachment(id: 10, url: "http://a.b/c.jpg", title: "My Title", content_id: "1fe8")],
79
77
  )
80
- expected_html_output = %{
78
+ expected_html_output = %(
81
79
  <figure id="attachment_10" class="image embedded">
82
80
  <div class="img"><img src="http://a.b/c.jpg" alt="My Title"></div>
83
81
  </figure>
84
- }
82
+ )
85
83
  assert_match(compress_html(expected_html_output), compress_html(rendered))
86
84
  end
87
85
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
 
5
3
  class GovspeakAttachmentsInlineTest < Minitest::Test
@@ -141,10 +139,10 @@ class GovspeakAttachmentsInlineTest < Minitest::Test
141
139
  number_of_pages: 2,
142
140
  )],
143
141
  )
144
- link = %{<a href="#{Regexp.quote('http://a.b/test.txt')}">My Attached Text File</a>}
145
- type = %{<span class="type">Plain text</span>}
146
- file_size = %{<span class="file-size">2 KB</span>}
147
- pages = %{<span class="page-length">2 pages</span>}
142
+ link = %(<a href="#{Regexp.quote('http://a.b/test.txt')}">My Attached Text File</a>)
143
+ type = %(<span class="type">Plain text</span>)
144
+ file_size = %(<span class="file-size">2 KB</span>)
145
+ pages = %(<span class="page-length">2 pages</span>)
148
146
  assert_match(/#{link}\s+\(#{type}, #{file_size}, #{pages}\)/, rendered)
149
147
  end
150
148
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
  require "govspeak_test_helper"
5
3
 
@@ -46,13 +44,13 @@ class GovspeakTest < Minitest::Test
46
44
  end
47
45
 
48
46
  test_given_govspeak "Text before the button with line breaks \n\n\n{button}[Start Now](http://www.gov.uk){/button}\n\n\n test after the button" do
49
- assert_html_output %{
47
+ assert_html_output %(
50
48
  <p>Text before the button with line breaks</p>
51
49
 
52
50
  <p><a class="gem-c-button govuk-button" role="button" href="http://www.gov.uk">Start Now</a></p>
53
51
 
54
52
  <p>test after the button</p>
55
- }
53
+ )
56
54
  assert_text_output "Text before the button with line breaks Start Now test after the button"
57
55
  end
58
56
 
@@ -82,23 +80,23 @@ class GovspeakTest < Minitest::Test
82
80
 
83
81
  # Make sure button renders when typical linebreaks are before it, seen in publishing applications
84
82
  test_given_govspeak "{button}[Line breaks](https://gov.uk/random){/button}\r\n\r\n{button}[Continue](https://gov.uk/random){/button}\r\n\r\n{button}[Continue](https://gov.uk/random){/button}" do
85
- assert_html_output %{
83
+ assert_html_output %(
86
84
  <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Line breaks</a></p>
87
85
 
88
86
  <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
89
87
 
90
88
  <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
91
- }
89
+ )
92
90
  end
93
91
 
94
92
  test_given_govspeak "{button}[More line breaks](https://gov.uk/random){/button}\n\n{button}[Continue](https://gov.uk/random){/button}\n\n{button}[Continue](https://gov.uk/random){/button}" do
95
- assert_html_output %{
93
+ assert_html_output %(
96
94
  <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">More line breaks</a></p>
97
95
 
98
96
  <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
99
97
 
100
98
  <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
101
- }
99
+ )
102
100
  end
103
101
 
104
102
  test_given_govspeak %{
@@ -114,7 +112,7 @@ class GovspeakTest < Minitest::Test
114
112
  lorem lorem lorem
115
113
  lorem lorem lorem
116
114
  } do
117
- assert_html_output %{
115
+ assert_html_output %(
118
116
  <h2 id="register-to-vote">Register to vote</h2>
119
117
 
120
118
  <p>Introduction text about the service.</p>
@@ -126,6 +124,6 @@ class GovspeakTest < Minitest::Test
126
124
 
127
125
  <p>lorem lorem lorem
128
126
  lorem lorem lorem</p>
129
- }
127
+ )
130
128
  end
131
129
  end
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
 
5
3
  class GovspeakContactsTest < Minitest::Test
@@ -61,7 +59,7 @@ class GovspeakContactsTest < Minitest::Test
61
59
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
62
60
 
63
61
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
64
- expected_html_output = %{
62
+ expected_html_output = %(
65
63
  <div id="contact_4f3383e4-48a2-4461-a41d-f85ea8b89ba0" class="contact postal-address">
66
64
  <div class="content">
67
65
  <h3>Government Digital Service</h3>
@@ -89,7 +87,7 @@ class GovspeakContactsTest < Minitest::Test
89
87
  </div>
90
88
  </div>
91
89
  </div>
92
- }
90
+ )
93
91
 
94
92
  assert_equal(compress_html(expected_html_output), compress_html(rendered))
95
93
  end
@@ -105,7 +103,7 @@ class GovspeakContactsTest < Minitest::Test
105
103
  contact = build_contact(post_addresses: [])
106
104
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
107
105
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
108
- expected_html_output = %{
106
+ expected_html_output = %(
109
107
  <div id="contact_4f3383e4-48a2-4461-a41d-f85ea8b89ba0" class="contact">
110
108
  <div class="content">
111
109
  <h3>Government Digital Service</h3>
@@ -127,7 +125,7 @@ class GovspeakContactsTest < Minitest::Test
127
125
  </div>
128
126
  </div>
129
127
  </div>
130
- }
128
+ )
131
129
  assert_equal(compress_html(expected_html_output), compress_html(rendered))
132
130
  end
133
131
 
@@ -140,11 +138,11 @@ class GovspeakContactsTest < Minitest::Test
140
138
  ])
141
139
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
142
140
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
143
- expected = %{
141
+ expected = %(
144
142
  <p class="adr">
145
143
  <span class="street-address">125 Kingsway</span>
146
144
  </p>
147
- }
145
+ )
148
146
  assert_match(compress_html(expected), compress_html(rendered))
149
147
  end
150
148
 
@@ -156,7 +154,7 @@ class GovspeakContactsTest < Minitest::Test
156
154
  ])
157
155
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
158
156
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
159
- refute_match(%{<p class="adr">}, compress_html(rendered))
157
+ refute_match(%(<p class="adr">), compress_html(rendered))
160
158
  end
161
159
 
162
160
  test "contact with an empty email address is not rendered" do
@@ -167,7 +165,7 @@ class GovspeakContactsTest < Minitest::Test
167
165
  ])
168
166
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
169
167
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
170
- refute_match(%{<p class="email">}, compress_html(rendered))
168
+ refute_match(%(<p class="email">), compress_html(rendered))
171
169
  end
172
170
 
173
171
  test "contact with an empty contact form is not rendered" do
@@ -178,7 +176,7 @@ class GovspeakContactsTest < Minitest::Test
178
176
  ])
179
177
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
180
178
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
181
- refute_match(%{<p class="contact_form_url">}, compress_html(rendered))
179
+ refute_match(%(<p class="contact_form_url">), compress_html(rendered))
182
180
  end
183
181
 
184
182
  test "contact with an empty phone number is not rendered" do
@@ -189,7 +187,7 @@ class GovspeakContactsTest < Minitest::Test
189
187
  ])
190
188
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
191
189
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
192
- refute_match(%{<p class="tel">}, compress_html(rendered))
190
+ refute_match(%(<p class="tel">), compress_html(rendered))
193
191
  end
194
192
 
195
193
  test "it auto links text in the description" do
@@ -197,7 +195,7 @@ class GovspeakContactsTest < Minitest::Test
197
195
 
198
196
  govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
199
197
  rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
200
- assert_match(%{<p class="comments">My description about <a href="https://www.gov.uk">https://www.gov.uk</a></p>},
198
+ assert_match(%(<p class="comments">My description about <a href="https://www.gov.uk">https://www.gov.uk</a></p>),
201
199
  compress_html(rendered))
202
200
  end
203
201
  end
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
 
5
3
  class GovspeakExtractContactContentIdsTest < Minitest::Test
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
  require "govspeak_test_helper"
5
3
 
@@ -20,40 +18,40 @@ class GovspeakImagesBangTest < Minitest::Test
20
18
  test "!!n syntax renders an image in options[:images]" do
21
19
  given_govspeak "!!1", images: [Image.new] do
22
20
  assert_html_output(
23
- %{<figure class="image embedded">} +
24
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
25
- %{</figure>},
21
+ %(<figure class="image embedded">) +
22
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
23
+ %(</figure>),
26
24
  )
27
25
  end
28
26
  end
29
27
 
30
28
  test "!!n syntax escapes alt text" do
31
- given_govspeak "!!1", images: [Image.new(alt_text: %{my alt '&"<>})] do
29
+ given_govspeak "!!1", images: [Image.new(alt_text: %(my alt '&"<>))] do
32
30
  assert_html_output(
33
- %{<figure class="image embedded">} +
34
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&amp;&quot;&lt;&gt;"></div>} +
35
- %{</figure>},
31
+ %(<figure class="image embedded">) +
32
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&amp;&quot;&lt;&gt;"></div>) +
33
+ %(</figure>),
36
34
  )
37
35
  end
38
36
  end
39
37
 
40
38
  test "!!n syntax renders nothing if not found" do
41
39
  doc = Govspeak::Document.new("!!1")
42
- assert_equal %{\n}, doc.to_html
40
+ assert_equal %(\n), doc.to_html
43
41
  end
44
42
 
45
43
  test "Image:image-id syntax renders nothing" do
46
44
  doc = Govspeak::Document.new("[Image:another-id]", images: [Image.new])
47
- assert_equal %{\n}, doc.to_html
45
+ assert_equal %(\n), doc.to_html
48
46
  end
49
47
 
50
48
  test "!!n syntax adds image caption if given" do
51
49
  given_govspeak "!!1", images: [Image.new(caption: "My Caption & so on")] do
52
50
  assert_html_output(
53
- %{<figure class="image embedded">} +
54
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
55
- %{<figcaption><p>My Caption &amp; so on</p></figcaption>} +
56
- %{</figure>},
51
+ %(<figure class="image embedded">) +
52
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
53
+ %(<figcaption><p>My Caption &amp; so on</p></figcaption>) +
54
+ %(</figure>),
57
55
  )
58
56
  end
59
57
  end
@@ -61,9 +59,9 @@ class GovspeakImagesBangTest < Minitest::Test
61
59
  test "!!n syntax ignores a blank caption" do
62
60
  given_govspeak "!!1", images: [Image.new(caption: " ")] do
63
61
  assert_html_output(
64
- %{<figure class="image embedded">} +
65
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
66
- %{</figure>},
62
+ %(<figure class="image embedded">) +
63
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
64
+ %(</figure>),
67
65
  )
68
66
  end
69
67
  end
@@ -71,10 +69,10 @@ class GovspeakImagesBangTest < Minitest::Test
71
69
  test "¡¡n syntax adds image credit if given" do
72
70
  given_govspeak "!!1", images: [Image.new(credit: "My Credit & so on")] do
73
71
  assert_html_output(
74
- %{<figure class="image embedded">} +
75
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
76
- %{<figcaption><p>Image credit: My Credit &amp; so on</p></figcaption>} +
77
- %{</figure>},
72
+ %(<figure class="image embedded">) +
73
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
74
+ %(<figcaption><p>Image credit: My Credit &amp; so on</p></figcaption>) +
75
+ %(</figure>),
78
76
  )
79
77
  end
80
78
  end
@@ -82,9 +80,9 @@ class GovspeakImagesBangTest < Minitest::Test
82
80
  test "!!n syntax ignores a blank credit" do
83
81
  given_govspeak "!!1", images: [Image.new(credit: " ")] do
84
82
  assert_html_output(
85
- %{<figure class="image embedded">} +
86
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
87
- %{</figure>},
83
+ %(<figure class="image embedded">) +
84
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
85
+ %(</figure>),
88
86
  )
89
87
  end
90
88
  end
@@ -92,13 +90,13 @@ class GovspeakImagesBangTest < Minitest::Test
92
90
  test "!!n syntax adds image caption and credit if given" do
93
91
  given_govspeak "!!1", images: [Image.new(caption: "My Caption & so on", credit: "My Credit & so on")] do
94
92
  assert_html_output(
95
- %{<figure class="image embedded">} +
96
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
97
- %{<figcaption>} +
98
- %{<p>My Caption &amp; so on</p>\n} +
99
- %{<p>Image credit: My Credit &amp; so on</p>} +
100
- %{</figcaption>} +
101
- %{</figure>},
93
+ %(<figure class="image embedded">) +
94
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
95
+ %(<figcaption>) +
96
+ %(<p>My Caption &amp; so on</p>\n) +
97
+ %(<p>Image credit: My Credit &amp; so on</p>) +
98
+ %(</figcaption>) +
99
+ %(</figure>),
102
100
  )
103
101
  end
104
102
  end
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require "test_helper"
4
2
  require "govspeak_test_helper"
5
3
 
@@ -16,35 +14,35 @@ class GovspeakImagesTest < Minitest::Test
16
14
  test "Image:image-id syntax renders an image in options[:images]" do
17
15
  given_govspeak "[Image:image-id]", images: [build_image] do
18
16
  assert_html_output(
19
- %{<figure class="image embedded">} +
20
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
21
- %{</figure>},
17
+ %(<figure class="image embedded">) +
18
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
19
+ %(</figure>),
22
20
  )
23
21
  end
24
22
  end
25
23
 
26
24
  test "Image:image-id syntax escapes alt text" do
27
- given_govspeak "[Image:image-id]", images: [build_image(alt_text: %{my alt '&"<>})] do
25
+ given_govspeak "[Image:image-id]", images: [build_image(alt_text: %(my alt '&"<>))] do
28
26
  assert_html_output(
29
- %{<figure class="image embedded">} +
30
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&amp;&quot;&lt;&gt;"></div>} +
31
- %{</figure>},
27
+ %(<figure class="image embedded">) +
28
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&amp;&quot;&lt;&gt;"></div>) +
29
+ %(</figure>),
32
30
  )
33
31
  end
34
32
  end
35
33
 
36
34
  test "Image:image-id syntax renders nothing if not found" do
37
35
  doc = Govspeak::Document.new("[Image:another-id]")
38
- assert_equal %{\n}, doc.to_html
36
+ assert_equal %(\n), doc.to_html
39
37
  end
40
38
 
41
39
  test "Image:image-id syntax adds image caption if given" do
42
40
  given_govspeak "[Image:image-id]", images: [build_image(caption: "My Caption & so on")] do
43
41
  assert_html_output(
44
- %{<figure class="image embedded">} +
45
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
46
- %{<figcaption><p>My Caption &amp; so on</p></figcaption>} +
47
- %{</figure>},
42
+ %(<figure class="image embedded">) +
43
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
44
+ %(<figcaption><p>My Caption &amp; so on</p></figcaption>) +
45
+ %(</figure>),
48
46
  )
49
47
  end
50
48
  end
@@ -52,9 +50,9 @@ class GovspeakImagesTest < Minitest::Test
52
50
  test "Image:image-id syntax ignores a blank caption" do
53
51
  given_govspeak "[Image:image-id]", images: [build_image(caption: " ")] do
54
52
  assert_html_output(
55
- %{<figure class="image embedded">} +
56
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
57
- %{</figure>},
53
+ %(<figure class="image embedded">) +
54
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
55
+ %(</figure>),
58
56
  )
59
57
  end
60
58
  end
@@ -62,10 +60,10 @@ class GovspeakImagesTest < Minitest::Test
62
60
  test "Image:image-id syntax adds image credit if given" do
63
61
  given_govspeak "[Image:image-id]", images: [build_image(credit: "My Credit & so on")] do
64
62
  assert_html_output(
65
- %{<figure class="image embedded">} +
66
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
67
- %{<figcaption><p>Image credit: My Credit &amp; so on</p></figcaption>} +
68
- %{</figure>},
63
+ %(<figure class="image embedded">) +
64
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
65
+ %(<figcaption><p>Image credit: My Credit &amp; so on</p></figcaption>) +
66
+ %(</figure>),
69
67
  )
70
68
  end
71
69
  end
@@ -73,9 +71,9 @@ class GovspeakImagesTest < Minitest::Test
73
71
  test "Image:image-id syntax ignores a blank credit" do
74
72
  given_govspeak "[Image:image-id]", images: [build_image(credit: " ")] do
75
73
  assert_html_output(
76
- %{<figure class="image embedded">} +
77
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
78
- %{</figure>},
74
+ %(<figure class="image embedded">) +
75
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
76
+ %(</figure>),
79
77
  )
80
78
  end
81
79
  end
@@ -83,13 +81,13 @@ class GovspeakImagesTest < Minitest::Test
83
81
  test "Image:image-id syntax adds image caption and credit if given" do
84
82
  given_govspeak "[Image:image-id]", images: [build_image(caption: "My Caption & so on", credit: "My Credit & so on")] do
85
83
  assert_html_output(
86
- %{<figure class="image embedded">} +
87
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
88
- %{<figcaption>} +
89
- %{<p>My Caption &amp; so on</p>\n} +
90
- %{<p>Image credit: My Credit &amp; so on</p>} +
91
- %{</figcaption>} +
92
- %{</figure>},
84
+ %(<figure class="image embedded">) +
85
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
86
+ %(<figcaption>) +
87
+ %(<p>My Caption &amp; so on</p>\n) +
88
+ %(<p>Image credit: My Credit &amp; so on</p>) +
89
+ %(</figcaption>) +
90
+ %(</figure>),
93
91
  )
94
92
  end
95
93
  end
@@ -101,18 +99,18 @@ class GovspeakImagesTest < Minitest::Test
101
99
 
102
100
  given_govspeak "[Image:image-id]", images: [build_image] do
103
101
  assert_html_output(
104
- %{<figure class="image embedded">} +
105
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
106
- %{</figure>},
102
+ %(<figure class="image embedded">) +
103
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
104
+ %(</figure>),
107
105
  )
108
106
  end
109
107
 
110
108
  given_govspeak "[Image:image-id] some text", images: [build_image] do
111
109
  assert_html_output(
112
- %{<figure class="image embedded">} +
113
- %{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
114
- %{</figure>\n} +
115
- %{<p>some text</p>},
110
+ %(<figure class="image embedded">) +
111
+ %(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
112
+ %(</figure>\n) +
113
+ %(<p>some text</p>),
116
114
  )
117
115
  end
118
116
  end