【问题标题】:RubyMine IDE Cannot Find Spec Files in Spec directoryRubyMine IDE 无法在 Spec 目录中找到 Spec 文件
【发布时间】:2017-09-20 17:02:53
【问题描述】:

我已经将一个 Ruby 项目加载到 RubyMine 中,它的规范文件像往常一样位于 spec 目录中。在任何单个规范文件上右键单击并选择“运行”可以正确运行它。在specs 目录上右键单击并选择“全部运行”会导致每个测试失败并显示以下消息:

加载失败:/Users/nathaniel/repos/close-web/spec/compositions/analysis/analysis_data_spec.rb:1 异常消息:无法加载此类文件 -- spec_helper

在启动配置中,“测试文件夹”似乎设置正确:

/Users/nathaniel/repos/close-web/spec

还有工作目录:

/Users/nathaniel/repos/close-web

Ruby 参数设置如下:

-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Itest

(在 RubyMine 网站上有一些迹象表明需要 -Itest。)在 Bundler 选项卡下,“在包的上下文中运行脚本”也被选中。我不清楚 RubyMine 还需要什么才能递归地查找和执行测试。从命令行运行它们可以正常工作:

~repos/closeweb $ bundle exec rspec spec
... (all the tests running)

Finished in 6 minutes 27 seconds (files took 13.39 seconds to load)
1054 examples, 0 failures, 108 pending

这里有什么配置错误导致所有测试都无法运行?

【问题讨论】:

  • 鉴于您的文件夹名为spec,而不是test,我认为您需要-Ispec,而不是-Itest
  • @TomLord 就是这样!谢谢你。我没有意识到那是那面旗帜的含义。如果你想回答我会接受的。

标签: ruby rspec rubymine


【解决方案1】:

鉴于您的文件夹名为spec,而不是test,您需要-Ispec,而不是-Itest

换句话说,您的 RubyMine 参数应该是:

-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Ispec

来自ruby man page

-I directory   Used to tell Ruby where to load the library scripts.
               Directory path will be added to the load-path variable ($:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-17
    • 2013-01-21
    • 2018-05-11
    • 2014-12-11
    • 2013-09-23
    • 1970-01-01
    相关资源
    最近更新 更多