Skip to content

Commit 1d27a05

Browse files
authored
test: get specs passing again (#34)
* updated the error messages and regexp to account for changes in Nokogiri * switched to using `eq` to compare error messages since that gives you an actual diff * added `net-smtp` as an explicit dev dependency as it is no longer being pulled in by `actionmailer` * added `net-imap` as an explicit dev dependency as v0.5.x requires Ruby v3.1.0+ * downgraded `actionpack` and `actionmailer` to v7.0.8.4 for now as `require 'action_mailer/railtie'` errors with a generic "cannot load file" message
1 parent f4f7a2c commit 1d27a05

File tree

6 files changed

+114
-96
lines changed

6 files changed

+114
-96
lines changed

Gemfile.lock

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,33 @@ PATH
77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
actionmailer (0.6.1)
11-
actionpack (>= 0.9.5)
12-
actionpack (7.0.8.5)
13-
actionview (= 7.0.8.5)
14-
activesupport (= 7.0.8.5)
10+
actionmailer (7.0.8.4)
11+
actionpack (= 7.0.8.4)
12+
actionview (= 7.0.8.4)
13+
activejob (= 7.0.8.4)
14+
activesupport (= 7.0.8.4)
15+
mail (~> 2.5, >= 2.5.4)
16+
net-imap
17+
net-pop
18+
net-smtp
19+
rails-dom-testing (~> 2.0)
20+
actionpack (7.0.8.4)
21+
actionview (= 7.0.8.4)
22+
activesupport (= 7.0.8.4)
1523
rack (~> 2.0, >= 2.2.4)
1624
rack-test (>= 0.6.3)
1725
rails-dom-testing (~> 2.0)
1826
rails-html-sanitizer (~> 1.0, >= 1.2.0)
19-
actionview (7.0.8.5)
20-
activesupport (= 7.0.8.5)
27+
actionview (7.0.8.4)
28+
activesupport (= 7.0.8.4)
2129
builder (~> 3.1)
2230
erubi (~> 1.4)
2331
rails-dom-testing (~> 2.0)
2432
rails-html-sanitizer (~> 1.1, >= 1.2.0)
25-
activesupport (7.0.8.5)
33+
activejob (7.0.8.4)
34+
activesupport (= 7.0.8.4)
35+
globalid (>= 0.3.6)
36+
activesupport (7.0.8.4)
2637
concurrent-ruby (~> 1.0, >= 1.0.2)
2738
i18n (>= 1.6, < 2)
2839
minitest (>= 5.1)
@@ -33,11 +44,14 @@ GEM
3344
coderay (1.1.3)
3445
concurrent-ruby (1.3.4)
3546
crass (1.0.6)
47+
date (3.4.1)
3648
diff-lcs (1.5.0)
3749
docile (1.4.0)
3850
erubi (1.13.0)
3951
fast_ignore (0.17.4)
40-
i18n (1.14.6)
52+
globalid (1.2.1)
53+
activesupport (>= 6.1)
54+
i18n (1.14.7)
4155
concurrent-ruby (~> 1.0)
4256
jaro_winkler (1.5.4)
4357
json (2.6.2)
@@ -53,6 +67,15 @@ GEM
5367
method_source (1.0.0)
5468
mini_mime (1.1.2)
5569
minitest (5.25.1)
70+
net-imap (0.4.22)
71+
date
72+
net-protocol
73+
net-pop (0.1.2)
74+
net-protocol
75+
net-protocol (0.2.2)
76+
timeout
77+
net-smtp (0.5.0)
78+
net-protocol
5679
nokogiri (1.15.6-arm64-darwin)
5780
racc (~> 1.4)
5881
nokogiri (1.15.6-x86_64-linux)
@@ -74,9 +97,9 @@ GEM
7497
rails-html-sanitizer (1.6.0)
7598
loofah (~> 2.21)
7699
nokogiri (~> 1.14)
77-
railties (7.0.8.5)
78-
actionpack (= 7.0.8.5)
79-
activesupport (= 7.0.8.5)
100+
railties (7.0.8.4)
101+
actionpack (= 7.0.8.4)
102+
activesupport (= 7.0.8.4)
80103
method_source
81104
rake (>= 12.2)
82105
thor (~> 1.0)
@@ -135,6 +158,7 @@ GEM
135158
terminal-table (3.0.2)
136159
unicode-display_width (>= 1.1.1, < 3)
137160
thor (1.2.1)
161+
timeout (0.4.3)
138162
tzinfo (2.0.6)
139163
concurrent-ruby (~> 1.0)
140164
unicode-display_width (2.3.0)
@@ -146,11 +170,13 @@ PLATFORMS
146170
x86_64-linux
147171

148172
DEPENDENCIES
149-
actionmailer
150-
activesupport
173+
actionmailer (= 7.0.8.4)
174+
activesupport (= 7.0.8.4)
151175
bundler (>= 2.0)
152176
leftovers
153177
mail
178+
net-imap (< 0.5.0)
179+
net-smtp
154180
pry
155181
railties
156182
rake (>= 12.0)

lib/validate_html.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ class Error < StandardError; end
2525
# # Parsed using Nokogiri::HTML5::DocumentFragment
2626
# # document saved at: [Configuration#snapshot_path]/1a8ce99806ddeccc3a5f2904ba07c7fa5ae4659d.html
2727
# #
28-
# # 1:28: ERROR: That tag isn't allowed here Currently open tags: html, strong, em.
28+
# # 1:28: ERROR: End tag 'strong' isn't allowed here. Currently open tags: html, strong, em.
2929
# # <strong><em>Very Emphasized</strong></em>
3030
# # ^
31-
# # 1:37: ERROR: That tag isn't allowed here Currently open tags: html.
31+
# # 1:37: ERROR: End tag 'em' isn't allowed here. Currently open tags: html.
3232
# # <strong><em>Very Emphasized</strong></em>
3333
# # ^
3434
# @see ValidateHTML.validate_html
@@ -63,10 +63,10 @@ class << self
6363
# # Parsed using Nokogiri::HTML5::DocumentFragment
6464
# # Document saved at: [Configuration#snapshot_path]/1a8ce99806ddeccc3a5f2904ba07c7fa5ae4659d.html
6565
# #
66-
# # 1:28: ERROR: That tag isn't allowed here Currently open tags: html, strong, em.
66+
# # 1:28: ERROR: End tag 'strong' isn't allowed here. Currently open tags: html, strong, em.
6767
# # <strong><em>Very Emphasized</strong></em>
6868
# # ^
69-
# # 1:37: ERROR: That tag isn't allowed here Currently open tags: html.
69+
# # 1:37: ERROR: End tag 'em' isn't allowed here. Currently open tags: html.
7070
# # <strong><em>Very Emphasized</strong></em>
7171
# # ^
7272
#

spec/validate_html/active_support_notification_handler_spec.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
}
1616

1717
expect { described_class.call(nil, nil, nil, nil, payload) }
18-
.to raise_error(
19-
ValidateHTML::InvalidHTMLError,
20-
<<~MESSAGE
18+
.to raise_error(ValidateHTML::InvalidHTMLError) do |err|
19+
expect(err.message).to eq <<~MESSAGE
2120
Invalid html
2221
Parsed using Nokogiri::HTML5::DocumentFragment
2322
document saved at: #{File.dirname(__dir__)}/tmp/test_snapshots/1a8ce99806ddeccc3a5f2904ba07c7fa5ae4659d.html
2423
25-
1:28: ERROR: That tag isn't allowed here Currently open tags: html, strong, em.
24+
1:28: ERROR: End tag 'strong' isn't allowed here. Currently open tags: html, strong, em.
2625
<strong><em>Very Emphasized</strong></em>
2726
^
28-
1:37: ERROR: That tag isn't allowed here Currently open tags: html.
27+
1:37: ERROR: End tag 'em' isn't allowed here. Currently open tags: html.
2928
<strong><em>Very Emphasized</strong></em>
3029
^
3130
MESSAGE
32-
)
31+
end
3332
end
3433

3534
it 'ignores non-turbo payloads' do

spec/validate_html/mailer_observer_spec.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@
1919
stub_config(snapshot_path: snapshot_path)
2020

2121
expect { described_class.perform(html_email) }
22-
.to raise_error(
23-
ValidateHTML::InvalidHTMLError,
24-
<<~MESSAGE
22+
.to raise_error(ValidateHTML::InvalidHTMLError) do |err|
23+
expect(err.message).to eq <<~MESSAGE
2524
Invalid html from email The Subject
2625
Parsed using Nokogiri::HTML5::DocumentFragment
2726
document saved at: #{File.dirname(__dir__)}/tmp/test_snapshots/1a8ce99806ddeccc3a5f2904ba07c7fa5ae4659d.html
2827
29-
1:28: ERROR: That tag isn't allowed here Currently open tags: html, strong, em.
28+
1:28: ERROR: End tag 'strong' isn't allowed here. Currently open tags: html, strong, em.
3029
<strong><em>Very Emphasized</strong></em>
3130
^
32-
1:37: ERROR: That tag isn't allowed here Currently open tags: html.
31+
1:37: ERROR: End tag 'em' isn't allowed here. Currently open tags: html.
3332
<strong><em>Very Emphasized</strong></em>
3433
^
3534
MESSAGE
36-
)
35+
end
3736
end
3837

3938
context 'with valid html' do

0 commit comments

Comments
 (0)