【发布时间】:2016-06-01 15:10:15
【问题描述】:
我正在为我的 Rails 项目编写一个命令行工具(使用 thor),它应该检索要运行的规范列表,然后运行它们。然而,这个工具在我的 Rails 项目的一个子目录中,它有自己的 Gemfile。目录结构如下:
- rails_project
- Gemfile
- command_line_tool
- commands.rb
- Gemfile
commands.rb中的命令调用函数:
def specs_command
specs_to_run = get_specs_to_run()
RSpec::Core::Runner.run(specs_to_run)
end
rails_project 显然在其Gemfile 中有Rails,但command_line_tool 没有,所以当我在commands.rb 中运行specs_command 时,它会因错误LoadError: cannot load such file -- rails 而失败,因为它试图在其中运行RSpec 规范父目录。有没有办法强制 RSpec 使用另一个项目的 Rails 依赖项?我希望能够在不将 Rails 作为依赖项添加到我的命令行工具的情况下做到这一点。
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 rspec thor