Class: RedminePluginSupport::RspecTask

Inherits:
GeneralTask
  • Object
show all
Defined in:
lib/redmine_plugin_support/rspec_task.rb

Instance Attribute Summary

Attributes inherited from GeneralTask

#name

Instance Method Summary collapse

Methods inherited from GeneralTask

#initialize

Constructor Details

This class inherits a constructor from RedminePluginSupport::GeneralTask

Instance Method Details

#defineObject



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
# File 'lib/redmine_plugin_support/rspec_task.rb', line 3

def define

  gem 'rspec'
  gem 'rspec-rails'
  require 'spec/rake/spectask'

  desc "Run all specs in spec directory (excluding plugin specs)"
  Spec::Rake::SpecTask.new(:spec) do |t|
    t.spec_opts = ['--options', "\"#{RedmineHelper.plugin_root}/spec/spec.opts\""]
    t.spec_files = FileList['spec/**/*_spec.rb']
  end
  
  namespace :spec do
    desc "Run all specs in spec directory with RCov (excluding plugin specs)"
    Spec::Rake::SpecTask.new(:rcov) do |t|
      t.spec_opts = ['--options', "\"#{RedmineHelper.plugin_root}/spec/spec.opts\""]
      t.spec_files = FileList['spec/**/*_spec.rb']
      t.rcov = true
      t.rcov_opts << ["--rails", "--sort=coverage", "--exclude '/var/lib/gems,spec,#{RedmineHelper.redmine_app},#{RedmineHelper.redmine_lib}'"]
    end
    
    desc "Print Specdoc for all specs (excluding plugin specs)"
    Spec::Rake::SpecTask.new(:doc) do |t|
      t.spec_opts = ["--format", "specdoc", "--dry-run"]
      t.spec_files = FileList['spec/**/*_spec.rb']
    end

    desc "Print Specdoc for all specs as HTML (excluding plugin specs)"
    Spec::Rake::SpecTask.new(:htmldoc) do |t|
      t.spec_opts = ["--format", "html:doc/rspec_report.html", "--loadby", "mtime"]
      t.spec_files = FileList['spec/**/*_spec.rb']
    end

    [:models, :controllers, :views, :helpers, :lib].each do |sub|
      desc "Run the specs under spec/#{sub}"
      Spec::Rake::SpecTask.new(sub) do |t|
        t.spec_opts = ['--options', "\"#{RedmineHelper.plugin_root}/spec/spec.opts\""]
        t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
      end
    end
  end

  
  self
end