Class: R19Cov::Rake::SpecTask

Inherits:
Spec::Rake::SpecTask
  • Object
show all
Defined in:
lib/r19cov/rake/spec_task.rb

Overview

A Rake task that runs coverage.

Example:

R19Cov::Rake::Task.new do |t|
end

This will create a task that can be run with:

rake r19cov

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :r19cov) ⇒ SpecTask

Returns a new instance of SpecTask.



22
23
24
# File 'lib/r19cov/rake/spec_task.rb', line 22

def initialize(name = :r19cov)
  super
end

Instance Attribute Details

#spec_scriptObject

Returns the value of attribute spec_script.



25
26
27
# File 'lib/r19cov/rake/spec_task.rb', line 25

def spec_script
  @spec_script
end

Instance Method Details

#defineObject

:nodoc:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/r19cov/rake/spec_task.rb', line 27

def define # :nodoc:
  rcov = true
  lib_path = libs.join(File::PATH_SEPARATOR)
  task name do
    RakeFileUtils.verbose(verbose) do
      unless spec_file_list.empty?
        # ruby [ruby_opts] -Ilib -S r19cov [r19cov_opts] bin/spec -- examples [spec_opts]
        cmd_parts = [ruby_cmd || RUBY]
        cmd_parts += ruby_opts
        cmd_parts << %[-I"#{lib_path}"]
        cmd_parts << "-S r19cov"
        cmd_parts << "-w" if warning
        cmd_parts << rcov_option_list if rcov
        cmd_parts << %[-o "#{rcov_dir}"] if rcov
        cmd_parts << %["#{spec_script}"]
        cmd_parts << "--"
        cmd_parts += spec_file_list.collect { |fn| %["#{fn}"] }
        cmd_parts << spec_option_list
        if out
          cmd_parts << %[> "#{out}"]
          STDERR.puts "The Spec::Rake::SpecTask#out attribute is DEPRECATED and will be removed in a future version. Use --format FORMAT:WHERE instead."
        end
        cmd = cmd_parts.join(" ")
        puts cmd if verbose
        unless system(cmd)
          STDERR.puts failure_message if failure_message
          raise("Command #{cmd} failed") if fail_on_error
        end
      end
    end
  end
  self
end

#rcov_option_listObject

:nodoc:



61
62
63
# File 'lib/r19cov/rake/spec_task.rb', line 61

def rcov_option_list # :nodoc:
  ENV['RCOV_OPTS'] || rcov_opts.join(" ") || ""
end