From dc91d7f64e5bf2fdb079e14d357f96952a320be1 Mon Sep 17 00:00:00 2001 From: Yudai Takada Date: Fri, 22 Mar 2024 06:53:55 +0900 Subject: [PATCH] Remove a case that is not negative examples in the capybara sheet (#2122) The above case is a new Bad case added by https://github.com/rstacruz/cheatsheets/pull/1798 . It is designated as Bad due to performance issues, but it is not actually a Negative example. In practice, the following would be the same test: ```ruby expect(page).to have_button('Save') !expect(page).to have_button('Save') ``` This is not an example that will appear on the capybara cheat sheet, because it is a problem with how RSpec is written. I think it should be removed because it creates confusion. --- capybara.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/capybara.md b/capybara.md index 04b0737b38..49cc8cd0f5 100644 --- a/capybara.md +++ b/capybara.md @@ -119,15 +119,15 @@ In RSpec, you can use `page.should` assertions. ### About negatives ```ruby -expect(page).to have_no_button('Save') # OK -``` -```ruby -expect(page).not_to have_button('Save') # OK +expect(page).to have_no_button('Save') ``` + ```ruby -!expect(page).to have_button('Save') # Bad +expect(page).not_to have_button('Save') ``` +The two above statements are functionally equivalent. + ## RSpec ### Matchers