Rspec2 与 Rcov 的问题

发布于 2024-10-09 08:16:39 字数 967 浏览 0 评论 0原文

在我的 Rakefile 中,我有一个如下定义的任务:

namespace :test do
  desc "Run all specs."
  RSpec::Core::RakeTask.new(:spec) do |t|
    t.pattern = 'spec/**/*_spec.rb'
    t.verbose = false
  end

  RSpec::Core::RakeTask.new(:coverage) do |t|
    t.rcov = true
    t.rcov_opts =  %q[--exclude "spec"]
    t.verbose = true
  end
end

运行 test:coverage 时,我得到以下信息:

./spec/foo_spec.rb:3: undefined method `describe' for main:Object (NoMethodError)
    from /Library/Ruby/Gems/1.8/gems/rcov-0.9.9/bin/rcov:516:in `load'
    from /Library/Ruby/Gems/1.8/gems/rcov-0.9.9/bin/rcov:516
    from /usr/bin/rcov:19:in `load'
    from /usr/bin/rcov:19
rake aborted!
ruby -S rcov -Ispec:lib --exclude "spec" "./spec/foo_spec.rb" failed

Below my gem list:

diff-lcs (1.1.2)
rake (0.8.7)
rcov (0.9.9)
rspec (2.3.0)
rspec-core (2.3.1)
rspec-expectations (2.3.0)
rspec-mocks (2.3.0)

Any idea?提前致谢。

In my Rakefile, I have a task defined like this:

namespace :test do
  desc "Run all specs."
  RSpec::Core::RakeTask.new(:spec) do |t|
    t.pattern = 'spec/**/*_spec.rb'
    t.verbose = false
  end

  RSpec::Core::RakeTask.new(:coverage) do |t|
    t.rcov = true
    t.rcov_opts =  %q[--exclude "spec"]
    t.verbose = true
  end
end

When running test:coverage, I get this:

./spec/foo_spec.rb:3: undefined method `describe' for main:Object (NoMethodError)
    from /Library/Ruby/Gems/1.8/gems/rcov-0.9.9/bin/rcov:516:in `load'
    from /Library/Ruby/Gems/1.8/gems/rcov-0.9.9/bin/rcov:516
    from /usr/bin/rcov:19:in `load'
    from /usr/bin/rcov:19
rake aborted!
ruby -S rcov -Ispec:lib --exclude "spec" "./spec/foo_spec.rb" failed

Below my gem list:

diff-lcs (1.1.2)
rake (0.8.7)
rcov (0.9.9)
rspec (2.3.0)
rspec-core (2.3.1)
rspec-expectations (2.3.0)
rspec-mocks (2.3.0)

Any idea? Thanks in advance.

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

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

发布评论

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

评论(1

定格我的天空 2024-10-16 08:16:40

David Chelimsky 提供的解决方案:
http://rubyforge.org/pipermail/rspec-users/2010-December /019077.html

require "rspec"

干杯。

The solution, from David Chelimsky:
http://rubyforge.org/pipermail/rspec-users/2010-December/019077.html

require "rspec"

Cheers.

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