mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Update matchers to non-deprecated protocol
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user