将Rails错误发送到RSpec输出 [英] Sending rails errors to rspec output

查看:69
本文介绍了将Rails错误发送到RSpec输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Capybara与rspec结合使用来进行Rails应用程序的集成测试.

I am using Capybara in combination with rspec for integration testing of rails apps.

我希望将测试期间生成的任何错误(路由错误,控制器中的错误,任何东西)打印为与rspec输出中的"puts"语句相同.这可能吗?另外,这是一个合理的主意,还是我很傻?

I would like any errors (routing errors, errors in a controller, anything) generated during a test to be printed the same as "puts" statements in rspec's output. Is this possible? Additionally, is this a reasonable idea, or am I just being silly?

推荐答案

将以下内容添加到我的spec_helper.rb文件中是可行的:

Adding the following to my spec_helper.rb file worked:

ActionController::Base.class_eval do
  def rescue_action(exception)
    raise exception
  end
end

这篇关于将Rails错误发送到RSpec输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆