Rspec错误:Diff不是模块

时间:2011-09-13 22:15:26

标签: ruby-on-rails rspec

继Ryan Bates后,他们全新转向rspec。

我得到了

Guard is now watching at '/Users/thealey/Source/rpd31'
Guard::RSpec is running, with RSpec 2!
Running all specs
/Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/diff-lcs-1.1.3/lib/diff/lcs.rb:3:in `': Diff is not a module (TypeError)
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-expectations-2.6.0/lib/rspec/expectations/differ.rb:1:in `'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-expectations-2.6.0/lib/rspec/expectations.rb:9:in `'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/expecting/with_rspec.rb:1:in `'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:207:in `block in expect_with'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:202:in `each'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:202:in `expect_with'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:184:in `expectation_frameworks'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:413:in `configure_expectation_framework'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:165:in `ensure_example_groups_are_configured'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:178:in `set_it_up'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:141:in `subclass'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:129:in `describe'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/dsl.rb:5:in `describe'
    from /Users/thealey/Source/rpd31/spec/requests/create_projects_spec.rb:3:in `'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
    from /Users/thealey/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'

Gemfile是

source 'http://rubygems.org'

gem 'rails', '3.0.10'


gem 'mysql2', '0.2.7'


gem "authlogic"
gem 'activesupport', '3.0.10'
gem 'cancan'
gem 'will_paginate', "~> 3.0"
gem 'calendar_date_select', :git => 'http://github.com/paneq/calendar_date_select.git', :branch => 'rails3test'
gem 'bluecloth'
gem 'rdiscount'
gem 'capybara'
gem 'paperclip'
gem 'mail'

有关如何解决此问题的任何想法。

编辑:我从Gemfile中删除了注释掉的行。

我把diff放到我的gemfile中没有变化。

这是捆绑的输出。

Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.10)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.10)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.10)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.2.19)
Using actionmailer (3.0.10)
Using arel (2.0.10)
Using activerecord (3.0.10)
Using activeresource (3.0.10)
Using addressable (2.2.6)
Using archive-tar-minitar (0.5.2)
Using authlogic (3.0.3)
Using crack (0.1.8)
Using httparty (0.7.8)
Using multipart-post (1.1.3)
Using faraday (0.7.4)
Using multi_json (1.0.3)
Using oauth2 (0.5.0)
Using bitly (0.6.1)
Using bluecloth (2.1.0)
Using bson (1.3.1)
Using bson_ext (1.3.1)
Using bundler (1.0.18)
Using calendar_date_select (1.16.1) from http://github.com/paneq/calendar_date_select.git (at rails3test)
Using cancan (1.6.5)
Using nokogiri (1.5.0)
Using ffi (1.0.9)
Using childprocess (0.2.2)
Using json_pure (1.6.0)
Using rubyzip (0.9.4)
Using selenium-webdriver (2.5.0)
Using xpath (0.1.4)
Using capybara (1.1.1)
Using chronic (0.6.4)
Using cocaine (0.2.0)
Using colored (1.2)
Using columnize (0.3.4)
Using daemons (1.1.4)
Using diff (0.3.6)
Using diff-lcs (1.1.3)
Using eventmachine (0.12.10)
Using factory_girl (2.1.0)
Using rdoc (3.9.4)
Using thor (0.14.6)
Using railties (3.0.10)
Using factory_girl_rails (1.2.0)
Using git_remote_branch (0.3.0)
Using googlecharts (1.6.7)
Using gravtastic (3.2.6)
Using guard (0.6.3)
Using guard-rspec (0.4.5)
Using htmldiff (0.0.1)
Using ruby_core_source (0.1.5)
Using linecache19 (0.5.12)
Using mysql2 (0.2.7)
Using net-ldap (0.2.2)
Using net-ping (1.5.0)
Using paperclip (2.4.1)
Using rails (3.0.10)
Using rdiscount (1.6.8)
Using ri_cal (0.8.8)
Using riddle (1.4.0)
Using rspec-core (2.6.4)
Using rspec-expectations (2.6.0)
Using rspec-mocks (2.6.0)
Using rspec (2.6.0)
Using rspec-rails (2.6.1)
Using ruby-debug-base19 (0.11.25)
Using ruby-debug19 (0.11.6)
Using seed_dump (0.3.4)
Using thin (1.2.11)
Using thinking-sphinx (2.0.1)
Using time_diff (0.2.1)
Using will_paginate (3.0.pre)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

1 个答案:

答案 0 :(得分:1)

我有同样的问题。在我的例子中,我有一个名为Diff的模型类(在diff.rb中定义)导致了这个问题。我已经重命名了我的课程/模块,现在一切都很好。我有点失望,可能会发生这种命名空间冲突。

其他用户也遇到了源自其他宝石的碰撞问题(例如:https://github.com/sunaku/tork/issues/3)。如果我正在解决问题,我会去你的gem目录(使用bundle show来获取你的任何一个宝石)并运行

find . -name diff.rb

这应该告诉你所有包含diff.rb文件的库。我一直在寻找一个更加模糊/不太积极维护的宝石作为罪魁祸首。您可能需要找到一个替代宝石(或者修复有问题的宝石!)来解决问题。