开发者

Rspec2 issue with Rcov

开发者 https://www.devze.com 2023-02-01 18:30 出处:网络
In my Rakefile, I have a task defined like this: namespace :test do desc \"Run all specs.\" RSpec::Core::RakeTask.new(:spec) do |t|

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 ad开发者_运维技巧vance.


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

require "rspec"

Cheers.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号