ruby-on-rails - 无法使用 RubyMine 运行 RSPec。RSpec 在 ubuntu 终端上运行良好
问题描述
我在使用 RubyMine 运行 RSpec 时遇到问题。每当我尝试使用 RubyMine 运行测试时,都会出现以下错误。但是,如果我使用普通的 Ubuntu 终端,一切正常。
有谁知道我为什么会收到这个错误?如果有任何 gem 问题或任何路径问题,那么我也不应该通过终端运行它,对吗?
/bin/bash -c "/home/meowcat/.rvm/bin/rvm ruby-2.6.6 do /home/meowcat/.rvm/rubies/ruby-2.6.6/bin/ruby /home/meowcat/.rvm/gems/ruby-2.6.6/bin/rspec /home/meowcat/project/myProject/spec/api/v1/api_controller_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format 'Spec::Runner::Formatter::TeamcityFormatter' --example ApiController"
Testing started at 2:27 AM ...
Warning! PATH is not properly set up, /home/meowcat/.rvm/gems/ruby-2.6.6/bin is not at first place.
<log>Usually this is caused by shell initialization files. Search for <code>PATH=...</code> entries.
You can also re-add RVM to your profile by running: <code>rvm get stable --auto-dotfiles</code>
To fix it temporarily in this shell session run: <code>rvm use ruby-2.6.6</code>
To ignore this error add <code>rvm_silence_path_mismatch_check_flag=1</code> to your <code>~/.rvmrc</code> file.
An error occurred while loading spec_helper. - Did you mean?
rspec ./spec/spec_helper.rb
Failure/Error: require 'mongoid-rspec'
Gem::ConflictError:
Unable to activate mongoid-5.4.1, because activemodel-5.0.7.2 conflicts with activemodel (~> 4.0)
# /home/meowcat/.rvm/gems/ruby-2.6.6/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `block in require'
# /home/meowcat/.rvm/gems/ruby-2.6.6/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:259:in `load_dependency'
# /home/meowcat/.rvm/gems/ruby-2.6.6/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `require'
# ./spec/spec_helper.rb:12:in `<top (required)>'
# ------------------
# --- Caused by: ---
# LoadError:
# cannot load such file -- mongoid-rspec
# /home/meowcat/.rvm/gems/ruby-2.6.6/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `block in require'
Run options: include {:full_description=>/ApiController/}
All examples were filtered out
解决方案
似乎它rspec
直接调用了命令而不使用bundle exec
,因此没有正确处理 gem 依赖项。
您可以尝试在 Rubymine 中启用运行您的 rspec 并启用捆绑程序上下文,以便可以正确加载 gem。配置见附图。
推荐阅读
- c# - 在 WebControl 的属性中看不到事件(如 DoubleClick)
- appium - Cucumber-jvm @after 与 Appium 驱动程序
- powerbi - 用于频繁更改数据的 DirectQuery 与 Import
- http - Flutter 错误:类型“AddressInfo”不是类型转换中“String”类型的子类型
- python - 优化字典循环求和值
- python-3.x - 如何连接到 API?
- javascript - 显示/隐藏多个元素的过渡
- python - 在 SciPy 中搜索函数 `LinearNDInterpolator` 的源代码
- python - 解析 HTML 页面以获取内容
和标签
- xml - 可以从 CLI 实际运行 xquery 吗?