0

当我尝试运行 rspec 或 autotest 时,我不断收到错误消息:

/Users/Craig/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.0.alpha.249/lib/sass/plugin.rb:35:in `<module:Plugin>': uninitialized constant Sass::Util (NameError)

从我的 Gemfile 中删除 sass 后,规范运行良好。

有没有办法告诉 rspec 忽略 gem?或者我该怎么做才能运行 rspec/autotest?为什么 rspec 仍然依赖 Gemfile 来运行?rake spec 工作正常,但运行 rspec /file/path 或 autotest 不行。

我的 gemfile 看起来像这样:

source "http://rubygems.org"

gem "rails", "3.0.5"

gem "grape"

gem "mongoid", "2.0.0.rc.7"
gem "bson_ext", "1.2.4"
gem "mongoid_search"
gem "will_paginate", :git => "https://github.com/mislav/will_paginate.git", :branch => "rails3"
gem "bluecloth", "2.0.0"

gem "devise", :git => "https://github.com/plataformatec/devise.git"
gem "oauth2"
gem "warden_oauth"
gem "devise_invitable", :git => "https://github.com/scambra/devise_invitable.git"

gem "simple_form", :git => "https://github.com/plataformatec/simple_form.git"
gem "haml", :git => "https://github.com/nex3/haml.git"
gem "compass", ">= 0.10.6"
gem "sass"
gem "fog"
gem "rmagick"
gem "carrierwave", :git => "https://github.com/jnicklas/carrierwave.git"
gem "jquery-rails"
gem "quasi", "0.1.0", :path => "./vendor/gems/quasi-0.1.0/"
gem "mongoid_slug", :require => "mongoid/slug", :git => "https://github.com/papercavalier/mongoid-slug.git"
gem "faker"
gem "jammit", :git => "https://github.com/caifara/jammit.git"
gem "sanitize"
gem "right_aws", :git => "https://github.com/rightscale/right_aws.git"

group :development do
  gem "yard", "0.6.4"
  gem "yard-dm", "0.1.1"
  gem "hpricot"
  gem "ruby_parser"
  gem "ruby-debug19"
  gem "rails3-generators",    :git => "https://github.com/indirect/rails3-generators.git"
  gem "haml-rails",           :git => "https://github.com/indirect/haml-rails.git"
  gem "hirb"
  gem "heroku_san", "1.0.8"
  gem "right_http_connection", :git => "https://github.com/rightscale/right_http_connection.git"
  gem "barista", :platforms => :ruby
  gem "therubyracer", :platforms => :ruby
end

group :development, :test do
  gem "rspec-rails",          :git => "https://github.com/rspec/rspec-rails.git"
  gem "whenever", :require => false
  gem "pathy"
end

group :test do
  gem "nokogiri" ,  "~> 1.4.4.0"
  gem "jasmine"
  gem "rspec",                :git => "https://github.com/rspec/rspec.git"
  gem "rspec-core",           :git => "https://github.com/rspec/rspec-core.git"
  gem "rspec-expectations",   :git => "https://github.com/rspec/rspec-expectations.git"
  gem "rspec-mocks",          :git => "https://github.com/rspec/rspec-mocks.git"
  gem "spork", "~> 0.9.0.rc", :git => "https://github.com/timcharper/spork.git"
  gem "steak", ">=1.0",       :git => "https://github.com/cavalle/steak.git"
  gem "capybara",             :git => "https://github.com/jnicklas/capybara.git"
  gem "fabrication",          :git => "https://github.com/paulelliott/fabrication.git"
end

group :production do
  gem "dalli"
end

这是我运行 gem list 时吐出的内容

aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.5)
actionpack (3.0.5)
activemodel (3.0.5)
activerecord (3.0.5)
activeresource (3.0.5)
activesupport (3.0.5)
addressable (2.2.4)
algorithms (0.3.0)
archive-tar-minitar (0.5.2)
arel (2.0.9)
autotest (4.4.6)
autotest-fsevent (0.2.5)
autotest-growl (0.2.9)
barista (1.0.0)
bcrypt-ruby (2.1.4)
bluecloth (2.0.0)
bson (1.2.4)
bson_ext (1.2.4)
builder (2.1.2)
bundler (1.0.10)
capybara (0.4.1.2)
celerity (0.8.8)
childprocess (0.1.7)
chunky_png (1.1.0)
closure-compiler (1.0.0)
coffee-script (2.1.3)
coffee-script-source (1.0.1)
columnize (0.3.2)
compass (0.10.6)
configuration (1.2.0)
culerity (0.2.15)
dalli (1.0.2)
diff-lcs (1.1.2)
erubis (2.6.6)
excon (0.5.6)
faker (0.9.5)
faraday (0.5.7)
ffi (0.6.3)
fog (0.6.0)
formatador (0.0.16)
grape (0.1.3)
haml (3.0.25)
heroku (1.18.0)
heroku_san (1.0.8)
hirb (0.4.0)
hpricot (0.8.4)
i18n (0.5.0)
iobuffer (1.0.0)
jasmine (1.0.1.1)
jquery-rails (0.2.7)
json (1.5.1)
json_pure (1.5.1)
launchy (0.3.7)
linecache19 (0.5.11)
mail (2.2.15)
mime-types (1.16)
mongo (1.2.4)
mongoid (2.0.0.rc.7)
mongoid_search (0.1.2)
multi_json (0.0.5)
multi_xml (0.2.1)
multipart-post (1.1.0)
net-ssh (2.1.0)
nokogiri (1.4.4)
oauth (0.4.4)
oauth2 (0.1.1)
orm_adapter (0.0.4)
pathy (0.0.4)
polyglot (0.3.1)
rack (1.2.1)
rack-jsonp (1.1.0)
rack-mount (0.6.13)
rack-test (0.5.7)
rails (3.0.5)
railties (3.0.5)
rake (0.8.7)
rest-client (1.6.1)
rev (0.3.2)
rmagick (2.13.1)
rspec (2.5.0)
rspec-core (2.5.1)
rspec-expectations (2.5.0)
rspec-mocks (2.5.0)
rspec-rails (2.5.0)
ruby-debug-base19 (0.11.24)
ruby-debug19 (0.11.6)
ruby-fsevent (0.2.1)
ruby-hmac (0.4.0)
ruby_core_source (0.1.4)
ruby_parser (2.0.6)
rubystats (0.2.3)
rubyzip (0.9.4)
sanitize (2.0.0)
sass (3.1.0.alpha.249, 3.1.0.alpha.221)
selenium-client (1.2.18)
selenium-rc (2.3.1)
selenium-webdriver (0.1.3)
sexp_processor (3.0.5)
spork (0.8.4)
stackdeck (0.2.0)
stringex (1.2.0)
sys-uname (0.8.5)
therubyracer (0.8.1)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.24)
warden (1.0.3)
warden_oauth (0.1.1)
watchr (0.7)
whenever (0.6.6)
xpath (0.1.3)
yard (0.6.4)
yard-dm (0.1.1)
yui-compressor (0.9.4)
ZenTest (4.5.0)
4

1 回答 1

1

不确定这是否相关,但在谷歌搜索该错误消息时,这篇文章出现在首位。

升级到 Rails 3.1 后出现以下异常:

/Library/Ruby/Gems/1.8/gems/sass-3.1.12/lib/sass/../sass/plugin/compiler.rb:29: uninitialized constant Sass::Util (NameError)
    from /Library/Ruby/Gems/1.8/gems/sass-3.1.12/lib/sass/../sass/plugin.rb:4
    from /Library/Ruby/Gems/1.8/gems/haml-3.1.4/lib/sass/rails3_shim.rb:15
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
    from /Library/Ruby/Gems/1.8/gems/haml-3.1.4/lib/sass/rails3_shim.rb:13
    from /Library/Ruby/Gems/1.8/gems/sass-3.1.12/lib/sass/../sass.rb:19
    from /Library/Ruby/Gems/1.8/gems/sass-3.1.12/lib/sass/version.rb:3
    from /Library/Ruby/Gems/1.8/gems/haml-3.1.4/lib/haml/util.rb:347:in `try_sass'
    from /Library/Ruby/Gems/1.8/gems/haml-3.1.4/lib/sass.rb:6

这是因为我在 config/initializer 中有一个旧的 compass.rb 文件。

删除该文件解决了我的问题

于 2012-01-26T16:27:33.390 回答