Skip to content

Commit

Permalink
add better html and validation specs for erb
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Jan 14, 2022
1 parent 5cca4e9 commit 98de9e7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Empty file added .better-html.yml
Empty file.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ group :development do
gem "web-console", "~> 4.2"
end

gem "better_html", "~> 1.0"
gem "bootsnap", "~> 1.9", require: false
gem "griddler-postmark", "~> 1.0", github: "r38y/griddler-postmark"
gem "honeybadger", "~> 4.9"
Expand Down
11 changes: 11 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
better_html (1.0.16)
actionview (>= 4.0)
activesupport (>= 4.0)
ast (~> 2.0)
erubi (~> 1.4)
html_tokenizer (~> 0.0.6)
parser (>= 2.4)
smart_properties
bindex (0.8.1)
bootsnap (1.9.4)
msgpack (~> 1.0)
Expand Down Expand Up @@ -123,6 +131,7 @@ GEM
hotwire-livereload (1.0.0)
listen (>= 3.0.0)
rails (>= 6.0.0)
html_tokenizer (0.0.7)
htmlentities (4.3.4)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -282,6 +291,7 @@ GEM
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
shellany (0.0.1)
smart_properties (1.17.0)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -324,6 +334,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
better_html (~> 1.0)
bootsnap (~> 1.9)
bundler-audit (~> 0.9.0)
debug (~> 1.4)
Expand Down
24 changes: 24 additions & 0 deletions spec/views/view_validation_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require "rails_helper"
require "better_html/test_helper/safe_erb_tester"

RSpec.describe "view validation" do
include BetterHtml::TestHelper::SafeErbTester

erb_files = Rails.root.join("app", "views")
.glob("**/{*.htm,*.html,*.htm.erb,*.html.erb,*.html+*.erb}")

erb_files.each do |filename|
pathname = filename.relative_path_from(Rails.root)

describe pathname do
it "has no missing javascript escapes" do
assert_erb_safety File.read(filename)
end

it "has no html errors" do
data = File.read(filename)
BetterHtml::BetterErb::ErubiImplementation.new(data).validate!
end
end
end
end

0 comments on commit 98de9e7

Please sign in to comment.