`load_missing_constant':未初始化的常量Mocha :: Standalone(NameError)

时间:2012-08-28 20:14:17

标签: ruby rspec-rails puppet

我将puppet-dashboard分叉,以便为报告选项卡添加一些过滤功能。我被要求为我的更改编写一些规范,但在尝试运行时遇到以下错误rake spec

/Users/gposton/src/puppet-dashboard/vendor/rails/activesupport/lib/active_support/test_case.rb:12: warning: already initialized constant Mocha
/Users/gposton/src/puppet-dashboard/vendor/rails/activesupport/lib/active_support/dependencies.rb:466:in `load_missing_constant': uninitialized constant Mocha::Standalone (NameError)
  from /Users/gposton/src/puppet-dashboard/vendor/rails/activesupport/lib/active_support/dependencies.rb:106:in `const_missing'
  from /Users/gposton/src/puppet-dashboard/vendor/gems/rspec-1.3.2/lib/spec/adapters/mock_frameworks/mocha.rb:12
  from /Users/gposton/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Users/gposton/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
  from /Users/gposton/src/puppet-dashboard/vendor/rails/activesupport/lib/active_support/dependencies.rb:184:in `require'
  from /Users/gposton/src/puppet-dashboard/vendor/gems/rspec-1.3.2/lib/spec/runner/options.rb:313:in `plugin_mock_framework'
  from /Users/gposton/src/puppet-dashboard/vendor/gems/rspec-1.3.2/lib/spec/runner/options.rb:139:in `run_examples'
  from /Users/gposton/src/puppet-dashboard/vendor/gems/rspec-1.3.2/lib/spec/runner/command_line.rb:9:in `run'
  from /Users/gposton/src/puppet-dashboard/vendor/gems/rspec-1.3.2/bin/spec:5
rake aborted!

有什么想法吗?

这是我的配置。

gposton:puppet-dashboard/ (master✗) $ gem list                                                                                                                                                                                                                       

*** LOCAL GEMS ***

actionpack (3.2.8)
activemodel (3.2.8)
activesupport (3.2.8)
ap (0.1.1)
builder (3.0.0)
bundler (1.1.3)
colorize (0.5.8)
crack (0.3.1)
daemons (1.0.10)
diff-lcs (1.1.3)
domain_name (0.5.3)
erubis (2.7.0)
factory_girl (2.6.4)
ffi (1.0.11, 0.6.3)
haml (3.1.7)
hike (1.2.1)
httparty (0.8.3)
httpclient (2.2.5)
i18n (0.6.0)
journey (1.0.4)
json (1.7.1)
libvirt (0.2.0)
mail (2.4.4)
mechanize (2.4)
metaclass (0.0.1)
mime-types (1.18)
mocha (0.12.3)
mogilefs-client (3.1.1)
multi_json (1.3.4)
multi_xml (0.4.4)
mysql (2.8.1)
net-http-digest_auth (1.2)
net-http-persistent (2.6)
net-scp (1.0.4)
net-ssh (2.3.0)
nokogiri (1.4.7)
ntlm-http (0.1.1)
polyglot (0.3.3)
rack (1.1.2)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
railties (3.2.8)
rake (0.9.2.2)
rdoc (3.12)
rspec (2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.2)
rspec-mocks (2.11.2)
rspec-rails (2.11.0)
ruby-libvirt (0.3.0)
rubygems-bundler (0.9.0)
rvm (1.11.3.3)
sass (3.2.1)
soap4r (1.5.8)
sprockets (2.1.3)
sqlite3 (1.3.6)
sys-filesystem (1.0.0, 0.3.4)
terminal-table (1.4.5)
thor (0.16.0)
thoughtbot-shoulda (2.11.1)
tilt (1.3.3)
treetop (1.4.10)
typhoeus (0.3.3)
unf (0.0.5)
unf_ext (0.0.4)
webrobots (0.0.13)
will_paginate (3.0.3)
xml-simple (1.1.1)

gposton:puppet-dashboard/ (master✗) $ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0]

可以在github

上找到该代码

1 个答案:

答案 0 :(得分:0)

使规范有效的最简单方法是使用Bundler

bundle install
bundle exec rake spec