From 131bf842a9f332a42b9e96cd15bf16339a028ae0 Mon Sep 17 00:00:00 2001 From: Andy Palmer Date: Thu, 2 Nov 2017 18:55:53 +1100 Subject: [PATCH] Update matchers to non-deprecated protocol --- spec/support/cancan_helper.rb | 2 +- spec/support/delayed_job_helper.rb | 4 ++-- spec/support/matchers/delegate_matchers.rb | 4 ++-- spec/support/matchers/select2_matchers.rb | 8 ++++---- spec/support/matchers/table_matchers.rb | 12 ++++++------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spec/support/cancan_helper.rb b/spec/support/cancan_helper.rb index e5390372f4..96e4ca1cdc 100644 --- a/spec/support/cancan_helper.rb +++ b/spec/support/cancan_helper.rb @@ -16,7 +16,7 @@ module Spree !ability_hash.diff(@ability_result).any? end - failure_message_for_should do |user| + failure_message do |user| ability_hash,options = expected ability_hash = {ability_hash => true} if ability_hash.is_a? Symbol # e.g.: :create ability_hash = ability_hash.inject({}){|_, i| _.merge({i=>true}) } if ability_hash.is_a? Array # e.g.: [:create, :read] => {:create=>true, :read=>true} diff --git a/spec/support/delayed_job_helper.rb b/spec/support/delayed_job_helper.rb index 61304e62d3..db094f98b8 100644 --- a/spec/support/delayed_job_helper.rb +++ b/spec/support/delayed_job_helper.rb @@ -59,11 +59,11 @@ module OpenFoodNetwork end end - failure_message_for_should do |event_proc| + failure_message do |event_proc| @exception || "expected #{klass} to be enqueued matching #{options.inspect} (#{@jobs_created.count} others enqueued)" end - failure_message_for_should_not do |event_proc| + failure_message_when_negated do |event_proc| @exception || "expected #{klass} to not be enqueued matching #{options.inspect}" end diff --git a/spec/support/matchers/delegate_matchers.rb b/spec/support/matchers/delegate_matchers.rb index 20e173a562..f036127a2b 100644 --- a/spec/support/matchers/delegate_matchers.rb +++ b/spec/support/matchers/delegate_matchers.rb @@ -26,11 +26,11 @@ RSpec::Matchers.define :delegate do |method| "delegate :#{@method} to its #{@to}#{@prefix ? ' with prefix' : ''}" end - failure_message_for_should do |text| + failure_message do |text| "expected #{@delegator} to delegate :#{@method} to its #{@to}#{@prefix ? ' with prefix' : ''}" end - failure_message_for_should_not do |text| + failure_message_when_negated do |text| "expected #{@delegator} not to delegate :#{@method} to its #{@to}#{@prefix ? ' with prefix' : ''}" end diff --git a/spec/support/matchers/select2_matchers.rb b/spec/support/matchers/select2_matchers.rb index 6ab4fd5788..58bfc690d8 100644 --- a/spec/support/matchers/select2_matchers.rb +++ b/spec/support/matchers/select2_matchers.rb @@ -4,7 +4,7 @@ RSpec::Matchers.define :have_select2 do |id, options={}| # http://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Matchers#has_select%3F-instance_method # TODO: Instead of passing in id, use a more general locator - match_for_should do |node| + match do |node| @id, @options, @node = id, options, node #id = find_label_by_text(locator) @@ -27,13 +27,13 @@ RSpec::Matchers.define :have_select2 do |id, options={}| results.all? end - failure_message_for_should do |actual| + failure_message do |actual| message = "expected to find select2 ##{@id}" message += " with #{@options.inspect}" if @options.any? message end - match_for_should_not do |node| + match_when_negated do |node| @id, @options, @node = id, options, node #id = find_label_by_text(locator) @@ -60,7 +60,7 @@ RSpec::Matchers.define :have_select2 do |id, options={}| results.any? end - failure_message_for_should_not do |actual| + failure_message_when_negated do |actual| message = "expected not to find select2 ##{@id}" message += " with #{@options.inspect}" if @options.any? message diff --git a/spec/support/matchers/table_matchers.rb b/spec/support/matchers/table_matchers.rb index 411b0b646f..0a4c3b1e09 100644 --- a/spec/support/matchers/table_matchers.rb +++ b/spec/support/matchers/table_matchers.rb @@ -1,24 +1,24 @@ RSpec::Matchers.define :have_table_row do |row| - match_for_should do |node| + match do |node| @row = row node.has_selector? "tr", text: row.join(" ").strip # Check for appearance rows_under(node).include? row # Robust check of columns end - match_for_should_not do |node| + match_when_negated do |node| @row = row node.has_no_selector? "tr", text: row.join(" ").strip # Check for appearance !rows_under(node).include? row # Robust check of columns end - failure_message_for_should do |text| + failure_message do |text| "expected to find table row #{@row}" end - failure_message_for_should_not do |text| + failure_message_when_negated do |text| "expected not to find table row #{@row}" end @@ -32,7 +32,7 @@ end # find("#my-table").should match_table [[...]] RSpec::Matchers.define :match_table do |expected_table| - match_for_should do |node| + match do |node| rows = node. all("tr"). map { |r| r.all("th,td").map { |c| c.text.strip } } @@ -62,7 +62,7 @@ RSpec::Matchers.define :match_table do |expected_table| @failure_message.nil? end - failure_message_for_should do |text| + failure_message do |text| @failure_message end