lib/capybara/spec/session/has_selector_spec.rb in capybara-3.12.0 vs lib/capybara/spec/session/has_selector_spec.rb in capybara-3.13.0
- old
+ new
@@ -54,10 +54,11 @@
end
context 'with text' do
it 'should discard all matches where the given string is not contained' do
expect(@session).to have_selector('//p//a', text: 'Redirect', count: 1)
+ expect(@session).to have_selector(:css, 'p a', text: 'Redirect', count: 1)
expect(@session).not_to have_selector('//p', text: 'Doesnotexist')
end
it 'should respect visibility setting' do
expect(@session).to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: false)
@@ -188,8 +189,14 @@
end
it 'should discard all matches where the given regexp is matched' do
expect(@session).not_to have_no_selector('//p//a', text: /re[dab]i/i, count: 1)
expect(@session).to have_no_selector('//p//a', text: /Red$/)
+ end
+
+ it 'should error when matching element exists' do
+ expect do
+ expect(@session).to have_no_selector('//h2', text: 'Header Class Test Five')
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
end
end
end