我使用的是Ubuntu 12.04 64bit。我刚刚重新安装了操作系统并使用RVM安装了Ruby / Rails。但是当我尝试运行Rspec测试时,我收到一个错误:
ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- spec_helper (LoadError)
我使用命令rails g rspec:install
我在spec目录下有spec_helper文件。 有谁知道它为什么不起作用?
只有当我从sublime文本2运行测试时才会出现错误。我已添加了以下链接中的测试:https://github.com/maltize/sublime-text-2-ruby-tests
我的Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
gem 'rspec-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
答案 0 :(得分:1)
从命令行运行Sublime Text 2
$ cd "to your app folder then"
$ subl .
这应该有效,并且在https://github.com/maltize/sublime-text-2-ruby-tests
中将其作为注释