【问题标题】:Why aren't the changes made inside a spec reflected in database used by a remote app?为什么规范中所做的更改没有反映在远程应用程序使用的数据库中?
【发布时间】:2018-09-05 22:16:42
【问题描述】:

我正在使用 Capybara 和 RSpec 编写功能测试,其中应用程序是远程的(即不是由 Capybara 启动的)。测试和应用程序共享同一个数据库。因此,我假设测试对数据库所做的任何更改也可用于远程应用程序。

但是,当我使用 Selenium 用我在测试步骤中创建的记录中的数据填写表单时,我收到“没有这样的记录”错误。

我的 RSpec 配置包括这一行:

RSpec.configure do |c|
  c.use_transactional_fixtures = false
end

我认为这将允许数据可用于 Selenium。但事实并非如此。

我的水豚配置是:

Capybara.javascript_driver = :headless_chrome
Capybara.app_host = 'http://selenium:5000'
Capybara.run_server = false

测试和被测应用都使用相同的数据库DATABASE_URL=postgres://postgres@db:5432/test_db

谁能帮帮我?

【问题讨论】:

    标签: ruby-on-rails selenium-webdriver capybara rspec-rails


    【解决方案1】:

    找出 DatabaseCleaner 正在添加事务块。

    DatabaseCleaner.strategy = :transaction
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多