A platform for community discussion. Free, open, simple.
DEV: Refactor chat service matchers
Loïc Guitautc20b381508e3
diff --git a/plugins/chat/spec/support/chat_service_matcher.rb b/plugins/chat/spec/support/chat_service_matcher.rbindex bdd2649bbd1..a75d1a798c4 100644--- a/plugins/chat/spec/support/chat_service_matcher.rb+++ b/plugins/chat/spec/support/chat_service_matcher.rb@@ -31,6 +31,10 @@ module Chaterror_message_with_inspection(message)end+ def description+ "fail a #{type} named '#{name}'"+ end+privatedef step_exists?@@ -46,7 +50,11 @@ module Chatenddef type- "step"+ self.class.name.split("::").last.sub("Fail", "").downcase+ end++ def step+ "result.#{type}.#{name}"enddef error_message_with_inspection(message)@@ -56,46 +64,9 @@ module Chatendclass FailContract < FailStep- attr_reader :error_message-- def step- "result.contract.#{name}"- end-- def type- "contract"- end-- def matches?(service)- super && has_error?- end-- def has_error?- result[step].errors.present?- end-- def failure_message- return "expected contract '#{step}' to have errors" unless has_error?- super- end-- def description- "fail a contract named '#{name}'"- endendclass FailPolicy < FailStep- def type- "policy"- end-- def step- "result.policy.#{name}"- end-- def description- "fail a policy named '#{name}'"- endendclass FailToFindModel < FailStep@@ -103,10 +74,6 @@ module Chat"model"end- def step- "result.model.#{name}"- end-def description"fail to find a model named '#{name}'"end