Rspec 错误:Diff 不是模块

发布于 2024-12-04 05:17:00 字数 8177 浏览 0 评论 0原文

继瑞安·贝茨之后,railscast 成为 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.

Following Ryan Bates railscast brand new to rspec.

I get

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 is

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'

any ideas about how to troubleshoot this appreciated.

Edit: I removed commented out lines from Gemfile.

I put diff into my gemfile no change.

This is the output of bundle.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰雪之触 2024-12-11 05:17:00

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

其他用户也遇到了源自其他 gem 的碰撞问题(例如:https://github.com/ sunaku/tork/issues/3)。如果我要解决该问题,我会转到您的 gem 目录(对任何一个 gem 使用 bundle show 来查找它们所在的位置)并运行

find 。 -name diff.rb

这应该告诉您包含 diff.rb 文件的所有库。我正在寻找一种更不起眼/维护较少的宝石作为罪魁祸首。您可能需要找到替代 gem(或贡献修复有问题的 gem!)来解决问题。

I had the identical issue. In my case I had a model class called Diff (defined in diff.rb) which led to the issue. I've renamed my class/module and all is well now. I'm somewhat disappointed that this sort of namespace collision could occur.

Other users have also encountered issues with collisions originating from other gems (eg: https://github.com/sunaku/tork/issues/3). If I were troubleshooting the issue, I'd go to your gem directory (use bundle show for any one of your gems to find where they live) and run

find . -name diff.rb

That should tell you all of the libraries that contain a diff.rb file. I'd be looking for one of the more obscure/less actively maintained gems to be the culprit. You'll likely need to find an alternative gem (or contribute a fix the offending gem!) to fix the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文