Class: RSpec::Core::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RSpec::Core::RakeTask
- Defined in:
- lib/rspec/core/rake_task.rb
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.
-
#gemfile ⇒ Object
Name of Gemfile to use.
-
#name ⇒ Object
Name of task.
-
#pattern ⇒ Object
Glob pattern to match files.
-
#rcov ⇒ Object
Use rcov for code coverage?.
-
#rcov_opts ⇒ Object
Command line options to pass to rcov.
-
#rcov_path ⇒ Object
Path to rcov.
-
#rspec_opts ⇒ Object
Command line options to pass to rspec.
-
#rspec_path ⇒ Object
Path to rspec.
-
#ruby_opts ⇒ Object
Command line options to pass to ruby.
-
#skip_bundler ⇒ Object
By default, if there is a Gemfile, the generated command will include ‘bundle exec’.
-
#verbose ⇒ Object
Use verbose output.
-
#warning ⇒ Object
Deprecated.
Instance Method Summary collapse
-
#initialize(*args) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
-
#spec_opts=(opts) ⇒ Object
Deprecated.
Constructor Details
#initialize(*args) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
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 |
# File 'lib/rspec/core/rake_task.rb', line 115 def initialize(*args) @name = args.shift || :spec @pattern, @rcov_path, @rcov_opts, @ruby_opts, @rspec_opts = nil, nil, nil, nil, nil @warning, @rcov, @skip_bundler = false, false, false @verbose, @fail_on_error = true, true @gemfile = 'Gemfile' yield self if block_given? @rcov_path ||= 'rcov' @rspec_path ||= 'rspec' @pattern ||= './spec/**/*_spec.rb' desc("Run RSpec code examples") unless ::Rake.application.last_comment task name do RakeFileUtils.send(:verbose, verbose) do if files_to_run.empty? puts "No examples matching #{pattern} could be found" else begin ruby(spec_command) rescue puts if raise("ruby #{spec_command} failed") if fail_on_error end end end end end |
Instance Attribute Details
#fail_on_error ⇒ Object
Whether or not to fail Rake when an error occurs (typically when examples fail).
default:
true
56 57 58 |
# File 'lib/rspec/core/rake_task.rb', line 56 def fail_on_error @fail_on_error end |
#failure_message ⇒ Object
A message to print to stderr when there are failures.
59 60 61 |
# File 'lib/rspec/core/rake_task.rb', line 59 def @failure_message end |
#gemfile ⇒ Object
Name of Gemfile to use
default:
Gemfile
36 37 38 |
# File 'lib/rspec/core/rake_task.rb', line 36 def gemfile @gemfile end |
#name ⇒ Object
Name of task.
default:
:spec
16 17 18 |
# File 'lib/rspec/core/rake_task.rb', line 16 def name @name end |
#pattern ⇒ Object
Glob pattern to match files.
default:
'spec/**/*_spec.rb'
22 23 24 |
# File 'lib/rspec/core/rake_task.rb', line 22 def pattern @pattern end |
#rcov ⇒ Object
Use rcov for code coverage?
default:
false
72 73 74 |
# File 'lib/rspec/core/rake_task.rb', line 72 def rcov @rcov end |
#rcov_opts ⇒ Object
Command line options to pass to rcov.
default:
nil
84 85 86 |
# File 'lib/rspec/core/rake_task.rb', line 84 def rcov_opts @rcov_opts end |
#rcov_path ⇒ Object
Path to rcov.
default:
'rcov'
78 79 80 |
# File 'lib/rspec/core/rake_task.rb', line 78 def rcov_path @rcov_path end |
#rspec_opts ⇒ Object
Command line options to pass to rspec.
default:
nil
102 103 104 |
# File 'lib/rspec/core/rake_task.rb', line 102 def rspec_opts @rspec_opts end |
#rspec_path ⇒ Object
Path to rspec
default:
'rspec'
96 97 98 |
# File 'lib/rspec/core/rake_task.rb', line 96 def rspec_path @rspec_path end |
#ruby_opts ⇒ Object
Command line options to pass to ruby.
default:
nil
90 91 92 |
# File 'lib/rspec/core/rake_task.rb', line 90 def ruby_opts @ruby_opts end |
#skip_bundler ⇒ Object
By default, if there is a Gemfile, the generated command will include ‘bundle exec’. Set this to true to ignore the presence of a Gemfile, and not add ‘bundle exec’ to the command.
default:
false
30 31 32 |
# File 'lib/rspec/core/rake_task.rb', line 30 def skip_bundler @skip_bundler end |
#verbose ⇒ Object
Use verbose output. If this is set to true, the task will print the executed spec command to stdout.
default:
true
66 67 68 |
# File 'lib/rspec/core/rake_task.rb', line 66 def verbose @verbose end |
#warning ⇒ Object
Deprecated. Use ruby_opts=“-w” instead.
When true, requests that the specs be run with the warning flag set. e.g. “ruby -w”
default:
false
45 46 47 |
# File 'lib/rspec/core/rake_task.rb', line 45 def warning @warning end |