如何将自定义文本添加到成功 rspec 消息中

Aug*_*aza 2 ruby rspec ruby-on-rails

我正在生成一些自动规范,并且我希望在期望成功的时候有一个自定义的成功消息。例如,我想要这样的报告:

Opportunity
  .rating_info
    where the real estate kind is Monoambiente
      and there aren't assigned values
        is 0
      when there are multiple combinations
        is has the expected value(run 45 different combinations)
Run Code Online (Sandbox Code Playgroud)

hd1*_*hd1 5

似乎可以通过使用自定义格式化程序

class PedrazaFormatter < BaseTextFormatter
        Formatters.register self, :example_passed

        def init(times = 0)
          self.times = times
        end

        def example_passed(_notification)
          output.print "Test was successful #{self.times} times"
        end
end
Run Code Online (Sandbox Code Playgroud)

我希望这有帮助。如果您还有其他问题,请告诉我。