govspeak 5.6.0 → 5.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  module GovspeakTestHelper
2
-
3
2
  def self.included(base)
4
3
  base.extend(ClassMethods)
5
4
  end
@@ -13,7 +12,7 @@ module GovspeakTestHelper
13
12
  end
14
13
 
15
14
  def document
16
- Govspeak::Document.new(@govspeak, @options.merge(:images => @images))
15
+ Govspeak::Document.new(@govspeak, @options.merge(images: @images))
17
16
  end
18
17
 
19
18
  def assert_text_output(raw_expected)
@@ -33,9 +32,7 @@ module GovspeakTestHelper
33
32
  if lines.first.empty?
34
33
  lines.delete_at(0)
35
34
  nonblanks = lines.reject { |l| l.match(/^ *$/) }
36
- indentation = nonblanks.map do |line|
37
- line.match(/^ */)[0].size
38
- end.min
35
+ indentation = nonblanks.map { |line| line.match(/^ */)[0].size }.min
39
36
  unindented = lines.map do |line|
40
37
  line[indentation..-1]
41
38
  end
@@ -52,13 +49,13 @@ module GovspeakTestHelper
52
49
  def show_linenumbers(text)
53
50
  lines = text.split "\n"
54
51
  digits = Math.log10(lines.size + 2).ceil
55
- lines.map.with_index do |line, i|
56
- "%#{digits}d: %s" % [i+1, line]
57
- end.join "\n"
52
+ lines.map
53
+ .with_index { |line, i| "%<number>#{digits}d: %<line>s" % { number: i + 1, line: line } }
54
+ .join("\n")
58
55
  end
59
56
  end
60
57
 
61
- def given_govspeak(govspeak, images=[], options = {}, &block)
58
+ def given_govspeak(govspeak, images = [], options = {}, &block)
62
59
  asserter = GovspeakAsserter.new(self, govspeak, images, options)
63
60
  asserter.instance_eval(&block)
64
61
  end
@@ -72,7 +69,7 @@ module GovspeakTestHelper
72
69
  end
73
70
 
74
71
  module ClassMethods
75
- def test_given_govspeak(govspeak, images=[], options = {}, &block)
72
+ def test_given_govspeak(govspeak, images = [], options = {}, &block)
76
73
  test "Given #{govspeak}" do
77
74
  given_govspeak(govspeak, images, options, &block)
78
75
  end
@@ -1,15 +1,14 @@
1
1
  require "test_helper"
2
2
 
3
3
  class HtmlSanitizerTest < Minitest::Test
4
-
5
4
  test "disallow a script tag" do
6
5
  html = "<script>alert('XSS')</script>"
7
6
  assert_equal "alert('XSS')", Govspeak::HtmlSanitizer.new(html).sanitize
8
7
  end
9
8
 
10
9
  test "disallow a javascript protocol in an attribute" do
11
- html = %q{<a href="javascript:alert(document.location);"
12
- title="Title">an example</a>}
10
+ html = '<a href="javascript:alert(document.location);"
11
+ title="Title">an example</a>'
13
12
  assert_equal "<a title=\"Title\">an example</a>", Govspeak::HtmlSanitizer.new(html).sanitize
14
13
  end
15
14
 
@@ -69,7 +68,7 @@ class HtmlSanitizerTest < Minitest::Test
69
68
 
70
69
 
71
70
  test "allows valid text-align properties on the style attribute for table cells and table headings" do
72
- ["left", "right", "center"].each do |alignment|
71
+ %w[left right center].each do |alignment|
73
72
  html = "<table><thead><tr><th style=\"text-align: #{alignment}\">thing</th></tr></thead><tbody><tr><td style=\"text-align: #{alignment}\">thing</td></tr></tbody></table>"
74
73
  assert_equal html, Govspeak::HtmlSanitizer.new(html).sanitize
75
74
  end
@@ -11,11 +11,11 @@ class HtmlValidatorTest < Minitest::Test
11
11
  "+ another bullet",
12
12
  "1. Numbered list",
13
13
  "s2. Step",
14
- """
14
+ "
15
15
  Table | Header
16
16
  - | -
17
17
  Build | cells
18
- """,
18
+ ",
19
19
  "This is [an example](/an-inline-link \"Title\") inline link.",
20
20
  "<http://example.com/>",
21
21
  "<address@example.com>",
@@ -34,7 +34,7 @@ class HtmlValidatorTest < Minitest::Test
34
34
  "{:/highlight-answer}",
35
35
  "---",
36
36
  "*[GDS]: Government Digital Service",
37
- """
37
+ "
38
38
  $P
39
39
 
40
40
  $I
@@ -49,7 +49,7 @@ class HtmlValidatorTest < Minitest::Test
49
49
  $AI
50
50
  $I
51
51
  $P
52
- """,
52
+ ",
53
53
  ":england:content goes here:england:",
54
54
  ":scotland:content goes here:scotland:"
55
55
  ]
@@ -63,13 +63,13 @@ class HtmlValidatorTest < Minitest::Test
63
63
  end
64
64
 
65
65
  test "disallow a javascript protocol in an attribute" do
66
- html = %q{<a href="javascript:alert(document.location);"
67
- title="Title">an example</a>}
66
+ html = '<a href="javascript:alert(document.location);"
67
+ title="Title">an example</a>'
68
68
  assert Govspeak::HtmlValidator.new(html).invalid?
69
69
  end
70
70
 
71
71
  test "disallow a javascript protocol in a Markdown link" do
72
- html = %q{This is [an example](javascript:alert(""); "Title") inline link.}
72
+ html = 'This is [an example](javascript:alert(""); "Title") inline link.'
73
73
  assert Govspeak::HtmlValidator.new(html).invalid?
74
74
  end
75
75
 
@@ -4,7 +4,6 @@ require 'test_helper'
4
4
  require 'ostruct'
5
5
 
6
6
  class HCardPresenterTest < Minitest::Test
7
-
8
7
  def unindent(html)
9
8
  html.gsub(/^\s+/, '')
10
9
  end
@@ -88,12 +87,11 @@ class HCardPresenterTest < Minitest::Test
88
87
  'postal-code' => 'Postcode',
89
88
  'locality' => 'Locality',
90
89
  'region' => 'Region',
91
- 'country-name' => 'Country'
92
- }
90
+ 'country-name' => 'Country' }
93
91
  end
94
92
 
95
93
  def gb_addr
96
- <<-EOF
94
+ <<-HTML
97
95
  <p class="adr">
98
96
  <span class="fn">Recipient</span><br />
99
97
  <span class="street-address">Street</span><br />
@@ -102,33 +100,33 @@ class HCardPresenterTest < Minitest::Test
102
100
  <span class="postal-code">Postcode</span><br />
103
101
  <span class="country-name">Country</span>
104
102
  </p>
105
- EOF
103
+ HTML
106
104
  end
107
105
 
108
106
  def es_addr
109
- <<-EOF
107
+ <<-HTML
110
108
  <p class="adr">
111
109
  <span class="fn">Recipient</span><br />
112
110
  <span class="street-address">Street</span><br />
113
111
  <span class="postal-code">Postcode</span> <span class="locality">Locality</span> <span class="region">Region</span><br />
114
112
  <span class="country-name">Country</span>
115
113
  </p>
116
- EOF
114
+ HTML
117
115
  end
118
116
 
119
117
  def jp_addr
120
- <<-EOF
118
+ <<-HTML
121
119
  <p class="adr">
122
120
  〒<span class="postal-code">Postcode</span><br />
123
121
  <span class="region">Region</span><span class="locality">Locality</span><span class="street-address">Street</span><br />
124
122
  <span class="fn">Recipient</span><br />
125
123
  <span class="country-name">Country</span>
126
124
  </p>
127
- EOF
125
+ HTML
128
126
  end
129
127
 
130
128
  def addr_without_region
131
- <<-EOF
129
+ <<-HTML
132
130
  <p class="adr">
133
131
  <span class="fn">Recipient</span><br />
134
132
  <span class="street-address">Street</span><br />
@@ -136,11 +134,11 @@ class HCardPresenterTest < Minitest::Test
136
134
  <span class="postal-code">Postcode</span><br />
137
135
  <span class="country-name">Country</span>
138
136
  </p>
139
- EOF
137
+ HTML
140
138
  end
141
139
 
142
140
  def addr_without_country
143
- <<-EOF
141
+ <<-HTML
144
142
  <p class="adr">
145
143
  <span class="fn">Recipient</span><br />
146
144
  <span class="street-address">Street</span><br />
@@ -148,6 +146,6 @@ class HCardPresenterTest < Minitest::Test
148
146
  <span class="region">Region</span><br />
149
147
  <span class="postal-code">Postcode</span>
150
148
  </p>
151
- EOF
149
+ HTML
152
150
  end
153
151
  end
@@ -14,11 +14,12 @@ require 'minitest/autorun'
14
14
  class Minitest::Test
15
15
  class << self
16
16
  def test(name, &block)
17
- clean_name = name.gsub(/\s+/,'_')
18
- method = "test_#{clean_name.gsub(/\s+/,'_')}".to_sym
19
- already_defined = instance_method(method) rescue false
20
- raise "#{method} exists" if already_defined
21
- define_method(method, &block)
17
+ clean_name = name.gsub(/\s+/, '_')
18
+ method = "test_#{clean_name.gsub(/\s+/, '_')}".to_sym
19
+ already_defined = instance_method(method) rescue false
20
+ raise "#{method} exists" if already_defined
21
+
22
+ define_method(method, &block)
22
23
  end
23
24
  end
24
25
  end
metadata CHANGED
@@ -1,181 +1,175 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govspeak
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 5.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-23 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: kramdown
14
+ name: actionview
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.15.0
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.15.0
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: htmlentities
28
+ name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4'
33
+ version: 2.3.8
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '3'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
- version: '4'
43
+ version: 2.3.8
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3'
41
47
  - !ruby/object:Gem::Dependency
42
- name: sanitize
48
+ name: commander
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '4.6'
53
+ version: '4.4'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '4.6'
60
+ version: '4.4'
55
61
  - !ruby/object:Gem::Dependency
56
- name: nokogiri
62
+ name: htmlentities
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '1.5'
67
+ version: '4'
62
68
  type: :runtime
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '1.5'
74
+ version: '4'
69
75
  - !ruby/object:Gem::Dependency
70
- name: addressable
76
+ name: i18n
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 2.3.8
76
- - - "<"
79
+ - - "~>"
77
80
  - !ruby/object:Gem::Version
78
- version: '3'
81
+ version: '0.7'
79
82
  type: :runtime
80
83
  prerelease: false
81
84
  version_requirements: !ruby/object:Gem::Requirement
82
85
  requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 2.3.8
86
- - - "<"
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '3'
88
+ version: '0.7'
89
89
  - !ruby/object:Gem::Dependency
90
- name: actionview
90
+ name: kramdown
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '4.1'
96
- - - "<"
93
+ - - "~>"
97
94
  - !ruby/object:Gem::Version
98
- version: '6'
95
+ version: 1.15.0
99
96
  type: :runtime
100
97
  prerelease: false
101
98
  version_requirements: !ruby/object:Gem::Requirement
102
99
  requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: '4.1'
106
- - - "<"
100
+ - - "~>"
107
101
  - !ruby/object:Gem::Version
108
- version: '6'
102
+ version: 1.15.0
109
103
  - !ruby/object:Gem::Dependency
110
- name: i18n
104
+ name: money
111
105
  requirement: !ruby/object:Gem::Requirement
112
106
  requirements:
113
107
  - - "~>"
114
108
  - !ruby/object:Gem::Version
115
- version: '0.7'
109
+ version: '6.7'
116
110
  type: :runtime
117
111
  prerelease: false
118
112
  version_requirements: !ruby/object:Gem::Requirement
119
113
  requirements:
120
114
  - - "~>"
121
115
  - !ruby/object:Gem::Version
122
- version: '0.7'
116
+ version: '6.7'
123
117
  - !ruby/object:Gem::Dependency
124
- name: money
118
+ name: nokogiri
125
119
  requirement: !ruby/object:Gem::Requirement
126
120
  requirements:
127
121
  - - "~>"
128
122
  - !ruby/object:Gem::Version
129
- version: '6.7'
123
+ version: '1.5'
130
124
  type: :runtime
131
125
  prerelease: false
132
126
  version_requirements: !ruby/object:Gem::Requirement
133
127
  requirements:
134
128
  - - "~>"
135
129
  - !ruby/object:Gem::Version
136
- version: '6.7'
130
+ version: '1.5'
137
131
  - !ruby/object:Gem::Dependency
138
- name: commander
132
+ name: rinku
139
133
  requirement: !ruby/object:Gem::Requirement
140
134
  requirements:
141
135
  - - "~>"
142
136
  - !ruby/object:Gem::Version
143
- version: '4.4'
137
+ version: '2.0'
144
138
  type: :runtime
145
139
  prerelease: false
146
140
  version_requirements: !ruby/object:Gem::Requirement
147
141
  requirements:
148
142
  - - "~>"
149
143
  - !ruby/object:Gem::Version
150
- version: '4.4'
144
+ version: '2.0'
151
145
  - !ruby/object:Gem::Dependency
152
- name: rake
146
+ name: sanitize
153
147
  requirement: !ruby/object:Gem::Requirement
154
148
  requirements:
155
149
  - - "~>"
156
150
  - !ruby/object:Gem::Version
157
- version: 0.9.0
158
- type: :development
151
+ version: '4.6'
152
+ type: :runtime
159
153
  prerelease: false
160
154
  version_requirements: !ruby/object:Gem::Requirement
161
155
  requirements:
162
156
  - - "~>"
163
157
  - !ruby/object:Gem::Version
164
- version: 0.9.0
158
+ version: '4.6'
165
159
  - !ruby/object:Gem::Dependency
166
- name: gem_publisher
160
+ name: govuk-lint
167
161
  requirement: !ruby/object:Gem::Requirement
168
162
  requirements:
169
- - - "~>"
163
+ - - ">="
170
164
  - !ruby/object:Gem::Version
171
- version: 1.1.1
165
+ version: '0'
172
166
  type: :development
173
167
  prerelease: false
174
168
  version_requirements: !ruby/object:Gem::Requirement
175
169
  requirements:
176
- - - "~>"
170
+ - - ">="
177
171
  - !ruby/object:Gem::Version
178
- version: 1.1.1
172
+ version: '0'
179
173
  - !ruby/object:Gem::Dependency
180
174
  name: minitest
181
175
  requirement: !ruby/object:Gem::Requirement
@@ -191,7 +185,7 @@ dependencies:
191
185
  - !ruby/object:Gem::Version
192
186
  version: 5.8.3
193
187
  - !ruby/object:Gem::Dependency
194
- name: simplecov
188
+ name: pry-byebug
195
189
  requirement: !ruby/object:Gem::Requirement
196
190
  requirements:
197
191
  - - ">="
@@ -205,21 +199,21 @@ dependencies:
205
199
  - !ruby/object:Gem::Version
206
200
  version: '0'
207
201
  - !ruby/object:Gem::Dependency
208
- name: simplecov-rcov
202
+ name: rake
209
203
  requirement: !ruby/object:Gem::Requirement
210
204
  requirements:
211
- - - ">="
205
+ - - "~>"
212
206
  - !ruby/object:Gem::Version
213
- version: '0'
207
+ version: 0.9.0
214
208
  type: :development
215
209
  prerelease: false
216
210
  version_requirements: !ruby/object:Gem::Requirement
217
211
  requirements:
218
- - - ">="
212
+ - - "~>"
219
213
  - !ruby/object:Gem::Version
220
- version: '0'
214
+ version: 0.9.0
221
215
  - !ruby/object:Gem::Dependency
222
- name: pry-byebug
216
+ name: simplecov
223
217
  requirement: !ruby/object:Gem::Requirement
224
218
  requirements:
225
219
  - - ">="
@@ -233,7 +227,7 @@ dependencies:
233
227
  - !ruby/object:Gem::Version
234
228
  version: '0'
235
229
  - !ruby/object:Gem::Dependency
236
- name: govuk-lint
230
+ name: simplecov-rcov
237
231
  requirement: !ruby/object:Gem::Requirement
238
232
  requirements:
239
233
  - - ">="
@@ -285,6 +279,7 @@ files:
285
279
  - test/govspeak_attachments_test.rb
286
280
  - test/govspeak_button_test.rb
287
281
  - test/govspeak_contacts_test.rb
282
+ - test/govspeak_extract_contact_content_ids_test.rb
288
283
  - test/govspeak_link_extractor_test.rb
289
284
  - test/govspeak_link_test.rb
290
285
  - test/govspeak_structured_headers_test.rb
@@ -313,23 +308,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
308
  version: '0'
314
309
  requirements: []
315
310
  rubyforge_project:
316
- rubygems_version: 2.5.1
311
+ rubygems_version: 2.7.6
317
312
  signing_key:
318
313
  specification_version: 4
319
314
  summary: Markup language for single domain
320
315
  test_files:
321
- - test/govspeak_link_extractor_test.rb
322
- - test/govspeak_structured_headers_test.rb
323
- - test/govspeak_button_test.rb
324
316
  - test/blockquote_extra_quote_remover_test.rb
325
317
  - test/govspeak_test_helper.rb
326
- - test/govspeak_link_test.rb
327
- - test/govspeak_contacts_test.rb
318
+ - test/govspeak_structured_headers_test.rb
319
+ - test/govspeak_attachments_image_test.rb
320
+ - test/govspeak_attachments_test.rb
328
321
  - test/test_helper.rb
329
- - test/html_validator_test.rb
330
- - test/html_sanitizer_test.rb
331
322
  - test/govspeak_attachments_inline_test.rb
323
+ - test/html_sanitizer_test.rb
324
+ - test/govspeak_button_test.rb
325
+ - test/html_validator_test.rb
326
+ - test/govspeak_extract_contact_content_ids_test.rb
332
327
  - test/govspeak_test.rb
333
- - test/govspeak_attachments_test.rb
334
- - test/govspeak_attachments_image_test.rb
328
+ - test/govspeak_link_extractor_test.rb
329
+ - test/govspeak_link_test.rb
330
+ - test/govspeak_contacts_test.rb
335
331
  - test/presenters/h_card_presenter_test.rb