From 2f1cf7693d39724307c79454bbb604e307baaca7 Mon Sep 17 00:00:00 2001 From: Szymon Lach Date: Thu, 30 Jan 2025 09:29:06 +0100 Subject: [PATCH] Add failure message when negate to have table row matcher --- lib/rspec_tapas/matchers/have_table_row.rb | 4 ++++ spec/rspec_tapas/matchers/have_table_row_spec.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/rspec_tapas/matchers/have_table_row.rb b/lib/rspec_tapas/matchers/have_table_row.rb index f3875d3..4137f47 100644 --- a/lib/rspec_tapas/matchers/have_table_row.rb +++ b/lib/rspec_tapas/matchers/have_table_row.rb @@ -25,6 +25,10 @@ module Matchers @failure_message end + failure_message_when_negated do |_actual| + "Expected not to find table row #{expected} but found" + end + private def with_delay diff --git a/spec/rspec_tapas/matchers/have_table_row_spec.rb b/spec/rspec_tapas/matchers/have_table_row_spec.rb index 43819e2..6f31586 100644 --- a/spec/rspec_tapas/matchers/have_table_row_spec.rb +++ b/spec/rspec_tapas/matchers/have_table_row_spec.rb @@ -19,6 +19,10 @@ expect(page).to have_table_row(0 => 'John', 1 => 27) expect(page).to have_table_row('John', 27) expect(page).to have_table_row(have_content('oh'), 27) + + expect do + expect(page).not_to have_table_row('Name' => 'John', 'Age' => 27) + end.to fail_with('Expected not to find table row {"Name"=>"John", "Age"=>27} but found') end end