Skip to content

Commit

Permalink
Add test for inline styles
Browse files Browse the repository at this point in the history
  • Loading branch information
pbstriker38 authored and rosa committed Oct 31, 2024
1 parent b89f01f commit bb63fab
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ GEM
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
better_html (2.1.1)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.7)
builder (3.2.4)
concurrent-ruby (1.3.3)
Expand Down Expand Up @@ -301,6 +308,7 @@ GEM
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
smart_properties (1.17.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand Down Expand Up @@ -345,6 +353,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
better_html
capybara!
debug
mission_control-jobs!
Expand Down
1 change: 1 addition & 0 deletions mission_control-jobs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rubocop", "~> 1.52.0"
spec.add_development_dependency "rubocop-performance"
spec.add_development_dependency "rubocop-rails-omakase"
spec.add_development_dependency "better_html"
spec.add_development_dependency "sprockets-rails"
spec.add_development_dependency "sqlite3"
spec.add_development_dependency "puma"
Expand Down
27 changes: 27 additions & 0 deletions test/mission_control/erb_inline_styles_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

require "test_helper"
require "better_html"
require "better_html/parser"
require "better_html/tree/tag"

class MissionControl::ErbInlineStylesTest < ActiveSupport::TestCase
ERB_GLOB = Rails.root.join(
"..", "..", "app", "views", "**", "{*.htm,*.html,*.htm.erb,*.html.erb,*.html+*.erb}"
)

Dir[ERB_GLOB].each do |filename|
pathname = Pathname.new(filename).relative_path_from(Rails.root)

test "No inline styles in /#{pathname.relative_path_from('../..')}" do
buffer = Parser::Source::Buffer.new("")
buffer.source = File.read(filename)
parser = BetterHtml::Parser.new(buffer)

parser.nodes_with_type(:tag).each do |tag_node|
tag = BetterHtml::Tree::Tag.from_node(tag_node)
assert_nil tag.attributes["style"]
end
end
end
end

0 comments on commit bb63fab

Please sign in to comment.