在Capybara-Webkit功能规格期间ActionCable无法连接 [英] ActionCable not connecting during capybara-webkit feature spec
问题描述
我在使用Capybara-webkit的功能规格时使用actioncable时遇到问题。 Actioncable在我的开发服务器上运行正常,但是在测试javascript似乎无法连接时。
I have a problem using actioncable with feature specs using Capybara-webkit. Actioncable is working perfectly on my development server, but when testing the javascript cant seem to connect.
这是在我的功能说明期间运行的javascript控制台的输出
This is the output from the javascript console which is running during my feature spec
WebSocket connection to 'ws://127.0.0.1:32789/cable' failed: Unexpected response code: 200
这是我当时的 test.log
的输出
GET "/cable" for 127.0.0.1 at 2017-01-26 13:33:23 +0000
GET "/cable/" for 127.0.0.1 at 2017-01-26 13:33:23 +0000
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
这很奇怪,因为根据日志看来它的连接很好,但是javascript抛出错误并停止执行...另外 200
如何显示错误代码? 200
状态代码不是总是表示 OK
吗?
Its strange because it seems like Its connecting fine according to the log, but the javascript throws an error and stops executing... Also how is 200
an error code? Doesn't 200
status code always mean OK
?
预先感谢
推荐答案
Capybara使用的默认服务器是:webrick,它不支持测试ActionCable(它将不断变化)每当Capybara 3.0发行时)。要将其切换为使用支持ActionCable进行测试的puma,可以将 Capybara.server =:puma
指定为Capybara配置的一部分。
The default server used by Capybara is :webrick which doesn't support testing ActionCable (it will be changing whenever Capybara 3.0 releases). To switch it to using puma which will support testing with ActionCable you can specify Capybara.server = :puma
as part of your Capybara configuration.
这篇关于在Capybara-Webkit功能规格期间ActionCable无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!