Forum: RSpec Rcov - Specifying rake tasks

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-02-03 21:00
I am trying to get a customized rcov rake task working.  What I have so
far looks like this:

desc "Rcov code coverage reports"

require 'rcov/rcovtask'
require 'spec/rake/spectask'
require 'cucumber/rake/task'

task  :rcov =>  "rcov:all"

namespace :rcov do

  Rcov::RcovTask.new(:all) do
    task :rcov => "rcov:cucumber"
  end

  Cucumber::Rake::Task.new(:cucumber) do |t|
    ...

  Spec::Rake::SpecTask.new(:rspec) do |t
    ...

  Rcov::RcovTask.new(:testunit) do |t|
    ...

Now, rake rcov:cucumber runs the cucumber rcov task as expected.
However, both rake rcov and rake rcov:all run rake rcov:testunit.  I
cannot fathom why.  Can someone explain this to me?
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-02-03 21:57
I am having a good deal of trouble grappling with how rake tasks are
processed. In my rcov.rake file I have this:

desc "Rcov code coverage reports"

require 'rcov/rcovtask'
require 'spec/rake/spectask'
require 'cucumber/rake/task'

#task  :rcov =>  "rcov:complete"

namespace :rcov do
  ...

  Cucumber::Rake::Task.new(:cucumber) do |t|
    puts "Why am I in the cucumber task?
    ...
  end

  Spec::Rake::SpecTask.new(:rspec) do |t|
    puts "Why am I in the rspec task?
    ...
    end
  end

  Rcov::RcovTask.new(:testunit) do |t|
    puts "Why am I in the rspec task?
    ...
  end

  Rcov::RcovTask.new(:complete) do
    puts "What the hell am I doing here?"
    ...
  end

end

When I run rake rcov:cucumber I see this:

Why am I in the cucumber task?
Why am I in the rspec task?
Why am I in the testunit task?
What the hell am I doing here?

This indicates that the entire rake task is processed regardless of the
argument given, which to me makes no sense at all.  Can somebody explain
why I am observing this behaviour?
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-02-04 00:05
James Byrne wrote:
> I am having a good deal of trouble grappling with how rake tasks are
> processed. In my rcov.rake file I have this:

I think that I have this straightened now.
Cucumber::Rake::Task.new(:cucumber) etc. are factory methods that are
processed as encountered by rake.
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-02-04 02:21
James Byrne wrote:

> I think that I have this straightened now.
> Cucumber::Rake::Task.new(:cucumber) etc. are factory methods that are
> processed as encountered by rake.

Having spent the day delving into Rake and the internals of factory
methods for Rake included with RSpec and Cucumber, I did a little write
up on how to create a custom Rake task for Rcov.  I would appreciate it
if people with a deeper knowledge of Rake and Rcov would review this
document and point out any errors or misunderstandings that it may
contain.

The URL is
http://wiki.rubyonrails.org/rails/pages/HowToCusto...

Thanks
This topic is locked and can not be replied to.