Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rspec&;bundle exec:“;rake spec";工作,但;rspec规范“;给予;未找到命令:rspec";缺少gem错误_Ruby On Rails_Rspec_Gem_Rake_Bundler - Fatal编程技术网

Ruby on rails Rspec&;bundle exec:“;rake spec";工作,但;rspec规范“;给予;未找到命令:rspec";缺少gem错误

Ruby on rails Rspec&;bundle exec:“;rake spec";工作,但;rspec规范“;给予;未找到命令:rspec";缺少gem错误,ruby-on-rails,rspec,gem,rake,bundler,Ruby On Rails,Rspec,Gem,Rake,Bundler,我在运行Rspec时遇到问题: 我的RSpec测试使用bundle exec-rake-spec正常运行,但是我在bundle exec-RSpec-spec中得到了一个丢失的gem错误 我正在使用Rails 4.1.0和Ruby 1.9.3p484(2013-11-22)[i386-mingw32]在带有Railsinstaller的Windows 7操作系统上 C:\RailsInstaller\Ruby1.9.3\myapp>bundle exec rspec spec bundler:

我在运行Rspec时遇到问题:

我的RSpec测试使用
bundle exec-rake-spec
正常运行,但是我在
bundle exec-RSpec-spec
中得到了一个丢失的gem错误

我正在使用Rails 4.1.0和Ruby 1.9.3p484(2013-11-22)[i386-mingw32]在带有Railsinstaller的Windows 7操作系统上


C:\RailsInstaller\Ruby1.9.3\myapp>bundle exec rspec spec
bundler: command not found: rspec
Install missing gem executables with `bundle install`
当我试图用
bundle exec rspec spec/models/project_spec.rb
之类的命令缩小我的规范测试范围时,我的所有测试都会运行,这大大降低了测试驱动开发的速度。我在多个带有规范测试的Rails项目上重复了这个问题,包括我从Github克隆的带有测试的项目。从Rails 4.0.1降级到Rails 4.0.0并没有解决问题。我的Bundler版本是1.6.2

我在C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems上安装了
rspec rails
gem,安装似乎运行良好:


C:\RailsInstaller\Ruby1.9.3\myapp>gem install rspec-rails
Successfully installed rspec-rails-2.14.2
Parsing documentation for rspec-rails-2.14.2
Done installing documentation for rspec-rails after 1 seconds
1 gem installed
使用
bundle exec-rake规范的工作规范测试示例
我的档案:
我的Gemfile.lock,我删除了它并多次运行了
捆绑安装

你能试试这个吗

bundle exec "rspec spec"

bundle exec rspec
问题1 您需要使用或正在使用的ruby版本不是
rspec
正在使用的版本
rspec
是指向
/usr/bin/rspec
的路径,遗憾的是,它的第一行是

#!/usr/bin/ruby
它将您的平台绑定到
/usr/bin/ruby
的任何版本。通过更改文件或在路径前面创建新的
rspec
来修复此问题:

#!/usr/bin/env ruby
(在某些系统上,它必须改为
#!/bin/env ruby

问题2 要将rspec与用户本地gem一起使用(即,在
$HOME/.gem
中),必须指定
$gem\u PATH
。基本上,
rspec
不尊重您的
$HOME/.gemrc
文件


也许
bundle exec
解决了上述问题,但对我来说,它产生了更多问题。

你能检查以下答案吗:两者都返回相同的错误:C:\RailsInstaller\Ruby1.9.3\myapp>bundle exec“rspec spec”bundler:command not found:rspec spec使用
bundle Install安装缺少的gem可执行文件我应该提到rspec spec在某个时候确实起了作用。最近发生了一些变化,我无法确定这可能是什么,但我怀疑这涉及到bundler和rake希望运行各自命令的路径。不。但Bundle show显示*rspec core(2.14.8)*rspec期望值(2.14.5)*rspec模拟(2.14.6)*rspec rails(2.14.2)卸载除GEM文件中列出的版本之外的所有其他版本,并在系统上安装多个版本时升级GEM文件中的rspec版本。因此,在使用rspec时,将加载最新的一个。。。它可能与文件中指定的不匹配
bundle exec rspec
#!/usr/bin/ruby
#!/usr/bin/env ruby