简体   繁体   English

无法使用 RubyMine 运行 RSPec。 RSpec 与 ubuntu 端子运行良好

[英]Unable to run RSPec using RubyMine. RSpec running fine with ubuntu terminal

I am facing issue with running RSpec using RubyMine.我在使用 RubyMine 运行 RSpec 时遇到问题。 I am getting the following error whenever I attempt to run test with RubyMine.每当我尝试使用 RubyMine 运行测试时,都会出现以下错误。 But if I use normal Ubuntu terminal, things all working fine.但如果我使用普通的 Ubuntu 终端,一切正常。

Do anyone know why I am getting this error?有谁知道我为什么会收到这个错误? If there is any gem issue or any path issue, then I should not be able to run it via terminal also right?如果有任何 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

My Conf:我的会议: 在此处输入图像描述

在此处输入图像描述

It seems like it invoked the rspec command directly without using bundle exec and hence the gem dependency wasn't handled correctly.似乎它直接调用了rspec命令而不使用bundle exec ,因此没有正确处理 gem 依赖项。

You can try enable running your rspec in Rubymine with bundler context enabled so that the gems can be loaded correctly.您可以尝试启用在 Rubymine 中运行 rspec 并启用捆绑程序上下文,以便可以正确加载 gem。 See attached image for the configuration.配置见附图。

Rubymine Rspec config screen Rubymine Rspec 配置屏幕

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM