A summary of data about the Ruby ecosystem.

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.

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


GitHub Events

Total
Last Year

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 Email 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:


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

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/rails/rails-dom-testing

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

gem.coop: rails-dom-testing

This gem can compare doms and assert certain elements exists in doms using Nokogiri.

rubygems.org: rails-dom-testing

This gem can compare doms and assert certain elements exists in doms using Nokogiri.


Dependencies

Gemfile.lock rubygems
  • 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
rails-dom-testing.gemspec rubygems
  • bundler >= 1.3 development
  • minitest >= 0 development
  • rake >= 0 development
  • activesupport >= 5.0.0
  • nokogiri >= 1.6
.github/workflows/ci.yml actions
  • actions/checkout v4 composite
  • ruby/setup-ruby v1 composite
Gemfile rubygems
  • rubocop >= 0 development
  • rubocop-minitest >= 0 development
  • rubocop-packaging >= 0 development
  • rubocop-performance >= 0 development
  • rubocop-rails >= 0 development
.github/workflows/release.yml actions
  • actions/checkout v4 composite
  • ruby/setup-ruby v1 composite
  • rubygems/configure-rubygems-credentials v1.0.0 composite

Score: 30.512392786247