简体   繁体   English

Rails:Rspec + Capybara + Remote形式?

[英]Rails: Rspec + Capybara + Remote form?

I have a quite big rails application whose main view consists of a complex, deeply nested form that is edited by different users along a predefined process flow (user1 inputs some info, user2 some more etc.). 我有一个很大的Rails应用程序,其主视图包含一个复杂的,深层嵌套的表单,该表单由不同的用户按照预定义的流程进行编辑(user1输入一些信息,user2输入更多信息,等等)。

I wrote a very long test using Rspec + Capybara in order to test the whole process, which worked fine until I switched to using a remote form (by setting remote: true). 为了测试整个过程,我使用Rspec + Capybara编写了一个很长的测试,在我切换到使用远程表单(通过设置remote:true)之前,它运行良好。

At this point, I would need to switch between using a js driver and a regular one in order to test different things within the same view (js when submitting, regular driver for everything else), but I cannot seem to find any example of how to do this. 在这一点上,我需要在使用js驱动程序和常规驱动程序之间切换,以便在同一视图中测试不同的事物(提交时使用js,其他所有功能都使用常规驱动程序),但是我似乎找不到任何有关如何去做这个。

The main issue is all the testing documentation I found assumes you can run separate tests, each with its own driver, just by setting js: true and doing some other changes, but my issue is I need everything to happen within the same test as the sequence of events is key. 主要问题是我发现的所有测试文档都假设您可以通过设置js:true并进行其他一些更改来运行单独的测试,每个测试都有自己的驱动程序,但是我的问题是我需要与事件的顺序是关键。

Any suggestion would be highly appreciated. 任何建议将不胜感激。

I dont believe you can nest a test using a different capybara driver while keeping changes of the above nested tests; 我不认为您可以使用其他的capybara驱动程序来嵌套测试,同时保留上述嵌套测试的更改。 the changes don't stick when changing from say rack_test to webkit or selenium. 从例如rack_test更改为Webkit或Selenium时,更改不会保留。 I had a similar problem of just getting capybara to detect changes with :remote => true set, ended up getting it to work with webkit driver. 我有一个类似的问题,只是让水豚使用:remote => true set来检测更改,最终使它与webkit驱动程序一起使用。 I posted what worked for me here: Capybara, Javascript and RSpec Integration Tests with :remote => true 我在这里发布了对我有用的东西: Capybara,Javascript和RSpec集成测试,带有:remote => true

You may just want to refactor out the steps needed to be done before the test with a remote form into a method that you can just call in a before block to keep your code clean. 您可能只想通过远程表单将测试之前需要完成的步骤重构为一种方法,您可以只调用before块以保持代码干净。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM