Today I Learned

hashrocket A Hashrocket project

Assert No Selector

Capybara assertions can be very simple. Today I learned about the assert_no_selector and assert_selector methods.

Then 'assert_no_selector works' do
  assert_no_selector '.nonexistent-text'
end

Then 'assert_selector works' do
  assert_selector '.existent-text'
end

And here's the view that makes them pass:

# app/views/home/index.html.haml
.existent-text

No RSpec required!

See More #testing TILs