[rspec-users] Using rcov and ouput to screen

aslak hellesoy aslak.hellesoy at gmail.com
Sat Aug 11 13:01:32 EDT 2007


On 8/11/07, barsalou <barjunk at attglobal.net> wrote:
>
> Sorry I left off the subject by accident...hopefully this will connect
> to the thread.
>
> Mike B.
> ----- Forwarded message from barjunk at attglobal.net -----
>     Date: Fri, 10 Aug 2007 14:33:18 -0800
>     From: barsalou <barjunk at attglobal.net>
> Reply-To: barsalou <barjunk at attglobal.net>
>       To: rspec-users at rubyforge.org
>
>
> Scott said:
>
> >> I'd like to output my rcov data to the screen in ascii instead of
> >> html...is that possible using the rake spec:rcov command?
>
> > Look at the RSpec gem's rdoc.  I believe it is something like
> > Rake::RcovTask.  An option can be provided to give rcov options.  Run
> >  rcov --help.
>
> This told me I needed the -T option to get what I wanted.
>
> Just to give a little more detail, I had to modify this file:
>
>
> vendor/plugins/rspec_on_rails/tasks/rspec.rake
>
> and in this section of code:
>
>   desc "Run all specs in spec directory with RCov (excluding plugin specs)"
>   Spec::Rake::SpecTask.new(:rcov) do |t|
>     t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
>     t.spec_files = FileList['spec/**/*_spec.rb']
>     t.rcov = true
>     t.rcov_opts = ['--exclude', 'spec', '--rails']
>   end
>
> Change this:
>
>     t.rcov_opts = ['--exclude', 'spec', '--rails']
>
> to this:
>
>     t.rcov_opts = ['--exclude', 'spec', '--rails', '-T']
>
>
> Any way to do this by passing a command line arg? like:
>
> rake spec:rcov -T                 <- This DOESN'T work.
>

>From Spec::Rake::SpecTask's RDoc (on trunk)

A Rake task that runs a set of RSpec contexts.

Example:

  Spec::Rake::SpecTask.new do |t|
    t.warning = true
    t.rcov = true
  end
This will create a task that can be run with:

  rake spec
If rake is invoked with a "SPEC=filename" command line option, then
the list of spec files will be overridden to include only the filename
specified on the command line. This provides an easy way to run just
one spec.

If rake is invoked with a "SPEC_OPTS=options" command line option,
then the given options will override the value of the spec_opts
attribute.

If rake is invoked with a "RCOV_OPTS=options" command line option,
then the given options will override the value of the rcov_opts
attribute.

Examples:

  rake spec                                      # run specs normally
  rake spec SPEC=just_one_file.rb                # run just one spec file.
  rake spec SPEC_OPTS="--diff"                   # enable diffing
  rake spec RCOV_OPTS="--aggregate myfile.txt"   # see rcov --help for details

Each attribute of this task may be a proc. This allows for lazy
evaluation, which is sometimes handy if you want to defer the
evaluation of an attribute value until the task is run (as opposed to
when it is defined).

>
>
> If it bugs me enough, maybe I'll submit a patch that allows an
> rcov.opts file like the spec.opts file. :)
>
>
> >
> > Also, is there somewhere that will allow me to search the mail
> > archives...I'm pretty sure someone else has asked similar questions.
> >
>
> > Google is your friend.  Rubyforge also has the mailing lists,
> > although they aren't searchable.
>
> Google is such a great resource...with abundant responses!  Sometimes
> this hinders my progress. :)
>
> Thanks for the hints.
>
> > Scott
>
>
> Mike B.
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
> ----- End forwarded message -----
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list