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.
-
#cucumber_desc ⇒ Object
The description for the Cucumber task.
-
#cucumber_name ⇒ Object
The name for the Cucumber task.
-
#output_path ⇒ Object
The base directory for all output files.
-
#rspec_desc ⇒ Object
The description for the RSpec task.
-
#rspec_name ⇒ Object
The name for the RSpec task.
-
#rspec_opts ⇒ Object
An array of additional options for the RSpec task.
-
#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.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/right_develop/ci/rake_task.rb', line 105 def initialize(*args) @ci_namespace = args.shift || :ci yield self if block_given? @output_path ||= 'measurement' @rspec_output ||= 'rspec.xml' @rspec_name ||= :spec @rspec_desc ||= "Run RSpec examples" @cucumber_name ||= :cucumber @cucumber_desc ||= "Run Cucumber examples" @rspec_opts ||= [] 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) default_opts = ['-r', 'right_develop/ci', '-f', JavaSpecFormatter.name, '-o', File.join(@output_path, 'rspec', @rspec_output)] # RSpec 2 desc @rspec_desc RSpec::Core::RakeTask.new(@rspec_name => :prep) do |t| t.rspec_opts = default_opts + @rspec_opts unless self.rspec_pattern.nil? t.pattern = self.rspec_pattern end end elsif defined?(::Spec::Rake::SpecTask) default_opts = ['-r', 'right_develop/ci', '-f', JavaSpecFormatter.name + ":" + File.join(@output_path, 'rspec', @rspec_output)] # RSpec 1 Spec::Rake::SpecTask.new(@rspec_name => :prep) do |t| desc @rspec_desc t.spec_opts = default_opts + @rspec_opts 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 Cucumber::Rake::Task.new(@cucumber_name, @cucumber_desc) 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 |
#cucumber_desc ⇒ Object
The description for the Cucumber task.
Default “Run Cucumber examples”
103 104 105 |
# File 'lib/right_develop/ci/rake_task.rb', line 103 def cucumber_desc @cucumber_desc end |
#cucumber_name ⇒ Object
The name for the Cucumber task.
Default :cucumber
98 99 100 |
# File 'lib/right_develop/ci/rake_task.rb', line 98 def cucumber_name @cucumber_name 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_desc ⇒ Object
The description for the RSpec task.
Default “Run RSpec examples”
85 86 87 |
# File 'lib/right_develop/ci/rake_task.rb', line 85 def rspec_desc @rspec_desc end |
#rspec_name ⇒ Object
The name for the RSpec task.
Default :spec
80 81 82 |
# File 'lib/right_develop/ci/rake_task.rb', line 80 def rspec_name @rspec_name end |
#rspec_opts ⇒ Object
An array of additional options for the RSpec task.
Default: []
Use like:
rspec_opts = ["-t", "~slow_specs"]
93 94 95 |
# File 'lib/right_develop/ci/rake_task.rb', line 93 def rspec_opts @rspec_opts 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 |