无法使用 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

我的会议:

enter image description here

enter image description here

解决方法

它似乎直接调用了 rspec 命令而不使用 bundle exec,因此没有正确处理 gem 依赖项。

您可以尝试在 Rubymine 中启用运行您的 rspec 并启用 bundler 上下文,以便可以正确加载 gem。配置见附图。

Rubymine Rspec config screen

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...