Class: RSpec::MultiprocessRunner::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RSpec::MultiprocessRunner::RakeTask
- Includes:
- Rake::DSL
- Defined in:
- lib/rspec/multiprocess_runner/rake_task.rb
Overview
Rake task to invoke ‘multispec`. Lots of it is copied from RSpec::Core::RakeTask.
Constant Summary collapse
- DEFAULT_MULTIRSPEC_PATH =
Default path to the multirspec executable.
File.('../../../../exe/multirspec', __FILE__)
Instance Attribute Summary collapse
-
#fail_on_error ⇒ Object
Whether or not to fail Rake when an error occurs (typically when examples fail).
-
#failure_message ⇒ Object
A message to print to stderr when there are failures.
-
#file_timeout_seconds ⇒ Object
The maximum number of seconds to allow a single spec file to run before killing it.
-
#files_or_directories ⇒ Object
File search will be limited to these directories or specific files.
-
#multirspec_path ⇒ Object
Path to the multispec executable.
-
#name ⇒ Object
Name of task.
-
#pattern ⇒ Object
Files matching this pattern will be loaded.
-
#rspec_opts ⇒ Object
Command line options to pass to the RSpec workers.
-
#verbose ⇒ Object
Use verbose output.
-
#worker_count ⇒ Object
The number of workers to run.
Instance Method Summary collapse
-
#initialize(*args, &task_block) ⇒ RakeTask
constructor
A new instance of RakeTask.
- #run_task(verbose) ⇒ Object
Constructor Details
#initialize(*args, &task_block) ⇒ RakeTask
Returns a new instance of RakeTask.
54 55 56 57 58 59 60 61 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 54 def initialize(*args, &task_block) @name = args.shift || :multispec @verbose = true @fail_on_error = true @multirspec_path = DEFAULT_MULTIRSPEC_PATH define(args, &task_block) end |
Instance Attribute Details
#fail_on_error ⇒ Object
Whether or not to fail Rake when an error occurs (typically when examples fail). Defaults to ‘true`.
38 39 40 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 38 def fail_on_error @fail_on_error end |
#failure_message ⇒ Object
A message to print to stderr when there are failures.
41 42 43 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 41 def @failure_message end |
#file_timeout_seconds ⇒ Object
The maximum number of seconds to allow a single spec file to run before killing it. Defaults to 300.
34 35 36 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 34 def file_timeout_seconds @file_timeout_seconds end |
#files_or_directories ⇒ Object
File search will be limited to these directories or specific files. Defaults to nil.
25 26 27 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 25 def files_or_directories @files_or_directories end |
#multirspec_path ⇒ Object
Path to the multispec executable. Defaults to the absolute path to the rspec binary from the loaded rspec-core gem.
49 50 51 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 49 def multirspec_path @multirspec_path end |
#name ⇒ Object
Name of task. Defaults to ‘:multispec`.
17 18 19 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 17 def name @name end |
#pattern ⇒ Object
Files matching this pattern will be loaded. Defaults to ‘’*/_spec.rb’‘.
21 22 23 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 21 def pattern @pattern end |
#rspec_opts ⇒ Object
Command line options to pass to the RSpec workers. Defaults to ‘nil`.
52 53 54 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 52 def rspec_opts @rspec_opts end |
#verbose ⇒ Object
Use verbose output. If this is set to true, the task will print the executed spec command to stdout. Defaults to ‘true`.
45 46 47 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 45 def verbose @verbose end |
#worker_count ⇒ Object
The number of workers to run. Defaults to 3.
30 31 32 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 30 def worker_count @worker_count end |
Instance Method Details
#run_task(verbose) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 64 def run_task(verbose) command = spec_command puts Shellwords.shelljoin(command) if verbose return if system(*command) puts if return unless fail_on_error $stderr.puts "#{command} failed" if verbose exit $?.exitstatus end |