1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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
|
require "rspec/core/rake_task"
require "rake/clean"
CLOBBER.include("coverage", "specdoc")
namespace :spec do
RSpec::Core::RakeTask.new(:rcov) do |t|
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = ['--color', '--format', 'documentation']
t.rcov_opts = [
'--exclude', 'lib\\/compat',
'--exclude', 'spec',
'--exclude', '\\.rvm\\/gems',
'--exclude', '1\\.8\\/gems',
'--exclude', '1\\.9\\/gems',
'--exclude', '\\.rvm',
'--exclude', '\\/Library\\/Ruby'
]
end
RSpec::Core::RakeTask.new(:normal) do |t|
t.pattern = FileList['spec/**/*_spec.rb'].exclude(/compat/)
t.rspec_opts = ['--color', '--format', 'documentation']
end
RSpec::Core::RakeTask.new(:all) do |t|
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = ['--color', '--format', 'documentation']
end
desc "Generate HTML Specdocs for all specs"
RSpec::Core::RakeTask.new(:specdoc) do |t|
specdoc_path = File.expand_path(
File.join(File.dirname(__FILE__), '..', 'documentation')
)
Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
output_file = File.join(specdoc_path, 'index.html')
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
t.fail_on_error = false
end
namespace :rcov do
desc "Browse the code coverage report."
task :browse => "spec:rcov" do
require "launchy"
Launchy::Browser.run("coverage/index.html")
end
end
end
desc "Alias to spec:normal"
task "spec" => "spec:normal"
|