https://github.com/rails/rails-dom-testing
Extracting DomAssertions and SelectorAssertions from ActionView.
https://github.com/rails/rails-dom-testing
Keywords from Contributors
activerecord rubygems activejob mvc feature-flag rack rspec ruby-gem crash-reporting feature
Last synced: about 6 hours ago
JSON representation
Repository metadata
Extracting DomAssertions and SelectorAssertions from ActionView.
- Host: GitHub
- URL: https://github.com/rails/rails-dom-testing
- Owner: rails
- License: mit
- Created: 2013-09-27T19:58:12.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2025-06-18T13:34:50.000Z (6 months ago)
- Last Synced: 2025-11-27T19:25:50.708Z (14 days ago)
- Language: Ruby
- Size: 246 KB
- Stars: 184
- Watchers: 16
- Forks: 60
- Open Issues: 7
- Releases: 17
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: MIT-LICENSE
README.md
Rails::Dom::Testing
This gem is responsible for comparing HTML doms and asserting that DOM elements are present in Rails applications.
Doms are compared via assert_dom_equal and assert_dom_not_equal.
Elements are asserted via assert_dom, assert_dom_encoded, assert_dom_email and a subset of the dom can be selected with css_select.
The gem is developed for Rails 4.2 and above, and will not work on previous versions.
Usage
Dom Assertions
assert_dom_equal '<h1>Lingua França</h1>', '<h1>Lingua França</h1>'
assert_dom_not_equal '<h1>Portuguese</h1>', '<h1>Danish</h1>'
Selector Assertions
# implicitly selects from the document_root_element
css_select '.hello' # => Nokogiri::XML::NodeSet of elements with hello class
# select from a supplied node. assert_dom asserts elements exist.
assert_dom document_root_element.at('.hello'), '.goodbye'
# select from a supplied node. assert_not_dom asserts elements do not exist.
assert_not_dom document_root_element.at('.hello'), '.goodbye'
# elements in CDATA encoded sections can also be selected
assert_dom_encoded '#out-of-your-element'
# assert elements within an html email exists
assert_dom_email '#you-got-mail'
The documentation in selector_assertions.rb goes into a lot more detail of how selector assertions can be used.
HTML versions
By default, assertions will use Nokogiri's HTML4 parser.
If Rails::Dom::Testing.default_html_version is set to :html5, then the assertions will use
Nokogiri's HTML5 parser. (If the HTML5 parser is not available on your platform, then a
NotImplementedError will be raised.)
When testing in a Rails application, the parser default can also be set by setting
Rails.application.config.dom_testing_default_html_version.
Some assertions support an html_version: keyword argument which can override the default for that
assertion. For example:
# compare DOMs built with the HTML5 parser
assert_dom_equal(expected, actual, html_version: :html5)
# compare DOMs built with the HTML4 parser
assert_dom_not_equal(expected, actual, html_version: :html4)
Please see documentation for individual assertions for more details.
Installation
Add this line to your application's Gemfile:
gem 'rails-dom-testing'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails-dom-testing
Read more
Under the hood the doms are parsed with Nokogiri, and you'll generally be working with these two classes:
Read more about Nokogiri:
Contributing to Rails::Dom::Testing
Rails::Dom::Testing is work of many contributors. You're encouraged to submit pull requests, propose
features and discuss issues.
See CONTRIBUTING.
License
Rails::Dom::Testing is released under the MIT License.
Owner metadata
- Name: Ruby on Rails
- Login: rails
- Email:
- Kind: organization
- Description:
- Website: https://rubyonrails.org/
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/4223?v=4
- Repositories: 116
- Last ynced at: 2023-04-09T03:40:20.529Z
- Profile URL: https://github.com/rails
GitHub Events
Total
- Create event: 2
- Release event: 1
- Issues event: 2
- Watch event: 8
- Issue comment event: 19
- Push event: 9
- Pull request review comment event: 1
- Pull request review event: 3
- Pull request event: 8
- Fork event: 2
Last Year
- Create event: 2
- Release event: 1
- Issues event: 2
- Watch event: 6
- Issue comment event: 19
- Push event: 9
- Pull request review comment event: 1
- Pull request review event: 3
- Pull request event: 8
- Fork event: 2
Committers metadata
Last synced: 12 days ago
Total Commits: 187
Total Committers: 33
Avg Commits per committer: 5.667
Development Distribution Score (DDS): 0.631
Commits in past year: 13
Committers in past year: 4
Avg Commits per committer in past year: 3.25
Development Distribution Score (DDS) in past year: 0.615
| Name | Commits | |
|---|---|---|
| Kasper Timm Hansen | k****h@g****m | 69 |
| Mike Dalessio | m****o@g****m | 24 |
| Rafael Mendonça França | r****l@r****g | 22 |
| Rafael Mendonça França | r****a@p****r | 15 |
| Akira Matsuda | r****e@d****p | 5 |
| Jye Harry | j****1@h****m | 5 |
| dependabot[bot] | 4****] | 4 |
| Sean Doyle | s****4@g****m | 4 |
| John Duff | d****n@g****m | 4 |
| Joshua Young | d****9@g****m | 3 |
| Abdelkader Boudih | t****e@g****m | 2 |
| Alex Ghiculescu | a****x@t****o | 2 |
| Dan Rice | d****n@z****m | 2 |
| David Heinemeier Hansson | d****d@l****m | 2 |
| Guo Xiang Tan | t****d@h****m | 2 |
| James Coleman | j****1@g****m | 2 |
| Matthew Draper | m****w@t****t | 2 |
| yuuji.yaginuma | y****a@g****m | 2 |
| Arthur Neves | a****n@g****m | 2 |
| maclover7 | me@j****e | 1 |
| m-nakamura145 | m****5@g****m | 1 |
| Yasuo Honda | y****a@g****m | 1 |
| Steven Peckins | s****s@i****u | 1 |
| Peter Goldstein | p****n@g****m | 1 |
| Nicolas Leger | n****r | 1 |
| Nicolas Gnyra | 1****7 | 1 |
| Mikey Gough | m****y@h****m | 1 |
| Jun Aruga | j****a@r****m | 1 |
| John Bampton | j****n@g****m | 1 |
| Issy Long | me@i****k | 1 |
| and 3 more... | ||
Committer domains:
- issyl0.co.uk: 1
- redhat.com: 1
- hey.com: 1
- illinois.edu: 1
- jonathanmoss.me: 1
- trebex.net: 1
- loudthinking.com: 1
- zoombody.com: 1
- tanda.co: 1
- dio.jp: 1
- plataformatec.com.br: 1
- rubyonrails.org: 1
Issue and Pull Request metadata
Last synced: 17 days ago
Total issues: 43
Total pull requests: 88
Average time to close issues: 5 months
Average time to close pull requests: about 2 months
Total issue authors: 31
Total pull request authors: 43
Average comments per issue: 3.79
Average comments per pull request: 2.25
Merged pull request: 67
Bot issues: 0
Bot pull requests: 5
Past year issues: 1
Past year pull requests: 9
Past year average time to close issues: 3 months
Past year average time to close pull requests: about 1 month
Past year issue authors: 1
Past year pull request authors: 4
Past year average comments per issue: 4.0
Past year average comments per pull request: 2.78
Past year merged pull request: 7
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- chancancode (6)
- rafaelfranca (3)
- kaspth (3)
- dnrce (3)
- khustochka (2)
- why-el (1)
- thebenedict (1)
- speckins (1)
- connorshea (1)
- jmgarnier (1)
- jaredbeck (1)
- codyrobbins (1)
- obfuscoder (1)
- voxik (1)
- obahareth (1)
Top Pull Request Authors
- flavorjones (11)
- kaspth (9)
- joshuay03 (5)
- dependabot[bot] (5)
- seanpdoyle (5)
- jyeharry (4)
- jduff (4)
- seuros (3)
- amatsuda (2)
- kirs (2)
- 3v0k4 (2)
- jcoleman (2)
- ghiculescu (2)
- m-nakamura145 (2)
- dnrce (2)
Top Issue Labels
- bug (5)
Top Pull Request Labels
- dependencies (5)
Package metadata
- Total packages: 2
-
Total downloads:
- rubygems: 1,187,546,966 total
- Total docker downloads: 1,642,128,344
- Total dependent packages: 21 (may contain duplicates)
- Total dependent repositories: 517,928 (may contain duplicates)
- Total versions: 34
- Total maintainers: 12
gem.coop: rails-dom-testing
This gem can compare doms and assert certain elements exists in doms using Nokogiri.
- Homepage: https://github.com/rails/rails-dom-testing
- Documentation: http://www.rubydoc.info/gems/rails-dom-testing/
- Licenses: MIT
- Latest release: 2.3.0 (published 7 months ago)
- Last Synced: 2025-12-09T13:30:18.988Z (3 days ago)
- Versions: 17
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 593,818,246 Total
- Docker Downloads: 821,064,172
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Downloads: 0.033%
- Average: 0.036%
- Docker downloads count: 0.113%
- Maintainers (12)
rubygems.org: rails-dom-testing
This gem can compare doms and assert certain elements exists in doms using Nokogiri.
- Homepage: https://github.com/rails/rails-dom-testing
- Documentation: http://www.rubydoc.info/gems/rails-dom-testing/
- Licenses: MIT
- Latest release: 2.3.0 (published 7 months ago)
- Last Synced: 2025-12-09T07:56:46.146Z (3 days ago)
- Versions: 17
- Dependent Packages: 21
- Dependent Repositories: 517,928
- Downloads: 593,728,720 Total
- Docker Downloads: 821,064,172
-
Rankings:
- Dependent repos count: 0.028%
- Downloads: 0.035%
- Docker downloads count: 0.144%
- Dependent packages count: 1.051%
- Average: 1.511%
- Forks count: 3.445%
- Stargazers count: 4.363%
- Maintainers (12)
Dependencies
- activesupport 6.1.2.1
- concurrent-ruby 1.1.8
- i18n 1.8.9
- minitest 5.10.1
- nokogiri 1.11.1
- racc 1.5.2
- rails-dom-testing 2.0.3
- rake 13.0.1
- tzinfo 2.0.4
- zeitwerk 2.4.2
- bundler >= 1.3 development
- minitest >= 0 development
- rake >= 0 development
- activesupport >= 5.0.0
- nokogiri >= 1.6
- actions/checkout v4 composite
- ruby/setup-ruby v1 composite
- rubocop >= 0 development
- rubocop-minitest >= 0 development
- rubocop-packaging >= 0 development
- rubocop-performance >= 0 development
- rubocop-rails >= 0 development
- actions/checkout v4 composite
- ruby/setup-ruby v1 composite
- rubygems/configure-rubygems-credentials v1.0.0 composite
Score: 30.512392786247