Class: RightDevelop::CI::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RightDevelop::CI::RakeTask
- Includes:
- Rake::DSL
- Defined in:
- lib/right_develop/ci/rake_task.rb
Overview
A Rake task definition that creates a CI namespace with appropriate tests.
Instance Attribute Summary collapse
-
#ci_namespace ⇒ Object
The namespace in which to define the continuous integration tasks.
-
#output_path ⇒ Object
The base directory for all output files.
-
#rspec_output ⇒ Object
Filename (without directory!) to which RSpec XML results should be written.
-
#rspec_pattern ⇒ Object
File glob to select which specs will be run with the spec task.
Instance Method Summary collapse
-
#initialize(*args) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(*args) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/right_develop/ci/rake_task.rb', line 77 def initialize(*args) @ci_namespace = args.shift || :ci yield self if block_given? @output_path ||= 'measurement' @rspec_output ||= 'rspec.xml' namespace @ci_namespace do task :prep do FileUtils.mkdir_p(@output_path) FileUtils.mkdir_p(File.join(@output_path, 'rspec')) FileUtils.mkdir_p(File.join(@output_path, 'cucumber')) end if defined?(::RSpec::Core::RakeTask) # RSpec 2 desc "Run RSpec examples" RSpec::Core::RakeTask.new(:spec => :prep) do |t| t.rspec_opts = ['-r', 'right_develop/ci', '-f', JavaSpecFormatter.name, '-o', File.join(@output_path, 'rspec', @rspec_output)] unless self.rspec_pattern.nil? t.pattern = self.rspec_pattern end end elsif defined?(::Spec::Rake::SpecTask) # RSpec 1 Spec::Rake::SpecTask.new(:spec => :prep) do |t| desc "Run RSpec Examples" t.spec_opts = ['-r', 'right_develop/ci', '-f', JavaSpecFormatter.name + ":" + File.join(@output_path, 'rspec', @rspec_output)] unless self.rspec_pattern.nil? t.spec_files = FileList[self.rspec_pattern] end end else raise LoadError, "Cannot define CI rake task: unsupported RSpec version" end desc "Run Cucumber features" Cucumber::Rake::Task.new do |t| t.cucumber_opts = ['--no-color', '--format', JavaCucumberFormatter.name, '--out', File.join(@output_path, 'cucumber')] end task :cucumber => [:prep] end end |
Instance Attribute Details
#ci_namespace ⇒ Object
The namespace in which to define the continuous integration tasks.
Default :ci
52 53 54 |
# File 'lib/right_develop/ci/rake_task.rb', line 52 def ci_namespace @ci_namespace end |
#output_path ⇒ Object
The base directory for all output files.
Default ‘measurement’
75 76 77 |
# File 'lib/right_develop/ci/rake_task.rb', line 75 def output_path @output_path end |
#rspec_output ⇒ Object
Filename (without directory!) to which RSpec XML results should be written. The CI task will take output_path, append “rspec” as a subdir and finally append this file name, to come up with a relative path for output. For example:
Default “rspec.xml”
output_path = "my_cool_ci"
rspec_output = "my_awesome_rspec.xml"
Given the options above, the CI harness would write RSpec results to:
my_cool_ci/rspec/my_awesome_rspec.xml
70 71 72 |
# File 'lib/right_develop/ci/rake_task.rb', line 70 def rspec_output @rspec_output end |
#rspec_pattern ⇒ Object
File glob to select which specs will be run with the spec task.
Default nil (let RSpec choose pattern)
57 58 59 |
# File 'lib/right_develop/ci/rake_task.rb', line 57 def rspec_pattern @rspec_pattern end |