Capybara服务器无法访问规范中创建的数据 [英] Capybara server can't access data created in a spec
问题描述
我正在运行Sinatra,Capybara和RSpec。我正在测试与Webkit无头浏览器的javascript交互。我正在使用工厂女孩创建我需要在测试中显示的数据。然后,我使用capybara与我的应用程序进行交互。在这些交互过程中,我在测试开始时创建的数据不再可用。它的创建没有问题,但是在控制器中调试时数据库为空。为什么我的数据库在控制器中为空,但在与控制器交互的规范中却为空?
I am running Sinatra, Capybara and RSpec. I am testing javascript interactions with webkit headless browser. I am using factory girl to create data that I need to be present for my test. I then use capybara to perform interactions with my application. During these interactions the data that I created at the start of the test is no longer available. It's created with no issue however when debugging in the controller the database is empty. Why is my database empty in the controller but not in the spec that interacts with the contorller?
推荐答案
尝试阅读本文(第3点)。我认为问题与数据库事务有关。
Try to read this article (the 3rd point). I think the problem is connected with DB transactions.
您可以通过单词 rails rspec共享连接$ c $搜索很多其他信息c>
这篇关于Capybara服务器无法访问规范中创建的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!