【问题标题】:Unable to run RSPec using RubyMine. RSpec running fine with ubuntu terminal无法使用 RubyMine 运行 RSPec。 RSpec 在 ubuntu 终端上运行良好
【发布时间】:2021-04-02 21:08:13
【问题描述】:

我在使用 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

我的会议:

【问题讨论】:

  • 这可能与跟踪器上的类似问题有关:youtrack.jetbrains.com/issue/RUBY-25745 问题是它很难重现。如果您可以在此处留下评论,描述您的设置并在可能的情况下分享项目示例,那就太好了。

标签: ruby-on-rails ruby intellij-idea rspec rubymine


【解决方案1】:

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

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

Rubymine Rspec config screen

【讨论】:

  • @CrazyCat 你能截屏你的 Rubymine rspec 配置并发布到这里吗?
  • @lee 我已经添加了截图....我已经把一些项目名称和用户名涂黑了。考虑为 /home/meowcat/project/myProject
猜你喜欢
  • 2012-09-27
  • 1970-01-01
  • 2016-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多