rails_html_validator 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rails_html_validator/matcher.rb +11 -3
- data/lib/rails_html_validator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4abb440380e02a02035d41a755b778db89e487c2125911c400f33b767b431d70
|
4
|
+
data.tar.gz: 2461fcbebe3720d0a9ff4d75bdc175f7e1eda661e9816ae1ef99c6466d9882a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 067a51960db789db0a3779382dca930fa5fa9e4e58a41325ccecf6b9d3f528970f5c64d11d1d62ad566574d118f4e7e1bc13ab1eac7112bceaf5cc593c9af5dc
|
7
|
+
data.tar.gz: a79500c0bacb8b4b7d08c25e6f64fae8e773efc1e84e111b538b0ffa36c4567bdc5c6a39d6c2bb232cf3682e3745903fef4b2ca001755fff41545015a09d3bbe
|
data/Gemfile.lock
CHANGED
@@ -2,11 +2,19 @@ require "nokogiri"
|
|
2
2
|
|
3
3
|
module RailsHtmlValidator
|
4
4
|
module Matchers
|
5
|
-
::RSpec::Matchers.define :exclude_html_tag_of do |
|
5
|
+
::RSpec::Matchers.define :exclude_html_tag_of do |attribute, tag:|
|
6
6
|
match do |model|
|
7
7
|
html = "<#{tag.to_s}></#{tag.to_s}>"
|
8
|
-
model.try("#{
|
9
|
-
|
8
|
+
model.try("#{attribute}=", html)
|
9
|
+
|
10
|
+
validators = model._validators[attribute].select do |v|
|
11
|
+
v.class == ActiveModel::Validations::HtmlValidator
|
12
|
+
end
|
13
|
+
return false if validators.blank?
|
14
|
+
|
15
|
+
validators.first.validate_each(model, attribute, html)
|
16
|
+
p model.errors.messages[attribute]
|
17
|
+
model.errors.messages[attribute].length > 0
|
10
18
|
end
|
11
19
|
end
|
12
20
|
end
|