Muk*_*rew 9 ruby rspec-rails web ruby-on-rails-4
我通过引入请求和响应模型来重构我的控制器,以便在演示之后执行一些挂在控制器周围的逻辑.我将所有响应和请求模型分别包含模块响应和请求.应用程序运行完美,但是当我运行测试时,我得到以下错误.
Failure/Error: Unable to find matching line from backtrace
RuntimeError:
Circular dependency detected while autoloading constant Responses::FolderContentResponse
Run Code Online (Sandbox Code Playgroud)
我的目录结构如下:
- app/
- models/
- responses /
注意:我已经看到了与此问题相关的问题,但是,他们的问题似乎与我的问题不相似.在我的情况下,它是随机发生的,只有在运行测试(RAILS TEST ENV)时,应用程序才能正常运行.
module Responses
class ContentResponse
include ActiveAttr::Model
#some attributes
#some methods
end
end
module Responses
class FolderContentResponse < ContentResponse
end
end
Run Code Online (Sandbox Code Playgroud)
FolderContent响应类继承自ContentResponse,后者具有FolderContent其他内容响应使用的更通用的方法.
Fre*_*ung 13
这听起来很像是Xavier Noria最近发现的问题.简而言之,即使预先加载所有应用程序代码的设置未激活(因为require并且朋友不是线程安全的),所以capybara会以多线程模式启动您的应用程序以进行测试
在早期版本中,它已针对rails 4.2进行了修复
config.allow_concurrency = false
Run Code Online (Sandbox Code Playgroud)
在test.rb应该做的伎俩
| 归档时间: |
|
| 查看次数: |
3255 次 |
| 最近记录: |