【问题标题】:'require': no such file to load — spec_helper'require':没有要加载的文件——spec_helper
【发布时间】:2013-07-07 20:10:50
【问题描述】:

我使用的是 Ubuntu 12.04 64 位。我刚刚重新安装了操作系统并使用 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)

我使用命令生成了 spec_helper 文件:rails g rspec:install

我在 spec 目录下有 spec_helper 文件。 有谁知道为什么它不起作用?

只有当我从 sublime text 2 运行测试时才会出现错误。我已经添加了如下链接中的测试:https://github.com/maltize/sublime-text-2-ruby-tests

我的宝石文件:

    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]

【问题讨论】:

  • 您在普通 spec 文件夹的子目录中是否有任何 spec 文件,或者您的 spec 目录布局是否有其他异常?
  • 我生成了集成测试,尝试运行并在 sublime 中得到了这个错误。当我从命令行运行 rspec spec 时,测试工作!但是它们在 Sublime 中不起作用,我不知道为什么。
  • 您是否查看了附加功能部分并尝试了这些设置? github.com/maltize/…
  • 是的,我做到了。仍然没有任何效果。我之前(在 Virtual Box 上)以这种方式安装过 Rails 和 Rspec 大约 3 次,但从未遇到过此类问题。我现在不知道怎么了!
  • 真的吗?没人知道为什么?

标签: ruby-on-rails ruby ruby-on-rails-4


【解决方案1】:

从命令行运行 Sublime Text 2

$ cd "to your app folder then"

$ subl .

这应该可以工作,他们在https://github.com/maltize/sublime-text-2-ruby-tests 中有注释

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-25
    • 2011-11-30
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多