loofah
Ruby library for HTML/XML transformation and sanitization (by flavorjones)
rails-dom-testing
Extracting DomAssertions and SelectorAssertions from ActionView. (by rails)
loofah | rails-dom-testing | |
---|---|---|
1 | 3 | |
923 | 171 | |
- | 2.9% | |
5.3 | 7.8 | |
7 days ago | 4 months ago | |
Ruby | Ruby | |
MIT License | MIT License |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
loofah
Posts with mentions or reviews of loofah.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-06-05.
-
Did you know Nokogiri now has opt-in HTML5 parsing?
loofah and rails-html-sanitizer gems follow nokogiri's lead to have opt-in HTML5 parsing (using nokogiri), using HTML5 classes -- if you use the default existing legacy API, you still get HTML4 parsing.
rails-dom-testing
Posts with mentions or reviews of rails-dom-testing.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-06-05.
-
Did you know Nokogiri now has opt-in HTML5 parsing?
Switching to HTML5 parsing for everything is a very good idea, but in a lot of cases it's not straightforward because -- blurgh -- people tend to write unit tests that assert on the exact output string. Currently Discourse is dealing with this, and I've started work to upgrade Mastodon and am hitting similar problems. (Worth noting that Rails provides a test helper, assert_dom_equals, that should cover the majority of use cases.)
-
https://np.reddit.com/r/rails/comments/mfj94y/is_there_a_way_to_unit_test_a_regular_view/gsujvx5/
class SomeViewTest < ActiveSupport::TestCase include Rails::Dom::Testing::Assertions::SelectorAssertions def test_some_view html = ActionController::Base.new.render_to_string "shared/_progress_indicator", layout: false, locals: { percent: 9 } # @selected is part of SelectorAssertions # https://github.com/rails/rails-dom-testing/blob/8f5acdfcb83a888c06592bad05475b7463998d1b/test/selector_assertions_test.rb#L332 @selected = Nokogiri::HTML.parse(html) # And then write the view tests assert_select "div" # etc. end end
-
Is there a way to unit test a regular view ?
# @selected is part of SelectorAssertions # https://github.com/rails/rails-dom-testing/blob/8f5acdfcb83a888c06592bad05475b7463998d1b/test/selector_assertions_test.rb#L332 @selected = Nokogiri::HTML.parse(html) # And then write the view tests assert_select "div" # etc.