为什么没有'rspec spec`在克隆的rails项目上工作?

时间:2018-03-22 20:22:44

标签: ruby-on-rails rspec

我刚刚通过rbenv在Windows子系统Linux(Ubuntu)中安装了Ruby和Rails。我按照GoRails安装指南进行操作,一切似乎都很完美。

当我开始一个新项目rails new myapp -T,并初始化rspec rspec --init,并运行一些测试rspec spec时,一切都运行正常。

我遇到的问题是,当我从Github克隆我的一个rails项目并运行rspec spec时,我得到了这个:

/home/damianrivas/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rack-2.0.4/lib/rack/builder.rb:146:in 'to_app': missing run or map statement (RuntimeError)

但是当我尝试bundle exec rspec spec时,一切正常。

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

bundle exec rspec spec executes the command in the context of Bundler. This means that the version specified in the Gemfile is run and Bundler takes care of properly placing the gem in the load path.

rspec spec executes whichever rspec is in your path which might not be the correct version at all.

An alternative to running bundle exec is creating binstubs:

bundle binstub rspec-core

This creates a "bundle wrapped" executable in the bin directory of the project.

You would then run RSpec with bin/rspec.