ruby-on-rails - 运行系统测试的新 Rails 项目出现 loaderror
问题描述
未经测试创建的 Rails 新项目 (6.1)
rails new [project name] -T
然后我安装了 rspec 5 并生成了一个输出以下错误的系统测试。
LoadError: cannot load such file --
capybara System test integration requires Rails >= 5.1
and has a hard dependency on a webserver and `capybara`,
please add capybara to your Gemfile and configure a webserver
(e.g. `Capybara.server = :webrick`) before attempting to use system specs.
No examples found.
解决方案
如果您在 Gemfile 中缺少 Capybara gem,如错误所示,您将收到此 LoadError。
如果您在没有测试的情况下生成 rails rails new [project] -T
,然后安装 RSpec,则可能会发生这种情况,因为它不会在 Gemfile 中添加 Capybara。
解决方案
添加一个测试组并将 capybara 放入其中可以让您像这样克服这个错误。
# Gemfile
group :test do
gem 'capybara', '>= 2.15'
end
推荐阅读
- java - 由于创建任务或键入 antilib:org.apache.ivy.ant.configure,构建失败
- firebase - 接收
() 缺少参数 - Flutter / GetX - c# - 如何在 Glyphs.FontURI 属性中指定 TTC 字体索引?
- sql - SQL Server 成功创建调用 NON-EXISTING 函数的存储过程
- c - 分配块的结构初始化导致分段错误
- android - 将 PDF 保存在 Android 11 上的外部下载目录中
- javascript - 如何在bingmap中获取比例尺
- javascript - 有没有更简单的递归方式来编写这个函数?
- python - python rss feed生成器给出错误的格式
- c++ - 我正在学习编程,我想知道是否有任何方法可以让这个代码只接受整数