Class: RSpec::Core::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RSpec::Core::RakeTask
- Includes:
- Rake::DSL
- 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.
-
#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.
-
#verbose ⇒ Object
Use verbose output.
Instance Method Summary collapse
- #gemfile= ⇒ Object deprecated Deprecated.
-
#initialize(*args) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
- #skip_bundler= ⇒ Object deprecated Deprecated.
- #spec_opts=(opts) ⇒ Object deprecated Deprecated.
- #warning=(true_or_false) ⇒ Object deprecated Deprecated.
Constructor Details
#initialize(*args) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
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 |
# File 'lib/rspec/core/rake_task.rb', line 112 def initialize(*args) @name = args.shift || :spec @pattern, @rcov_path, @rcov_opts, @ruby_opts, @rspec_opts = nil, nil, nil, nil, nil @warning, @rcov = false, false @verbose, @fail_on_error = true, true 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 puts spec_command if verbose success = system(spec_command) rescue puts if end raise("#{spec_command} failed") if fail_on_error unless success 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
52 53 54 |
# File 'lib/rspec/core/rake_task.rb', line 52 def fail_on_error @fail_on_error end |
#failure_message ⇒ Object
A message to print to stderr when there are failures.
55 56 57 |
# File 'lib/rspec/core/rake_task.rb', line 55 def @failure_message end |
#name ⇒ Object
Name of task.
default:
:spec
15 16 17 |
# File 'lib/rspec/core/rake_task.rb', line 15 def name @name end |
#pattern ⇒ Object
Glob pattern to match files.
default:
'spec/**/*_spec.rb'
21 22 23 |
# File 'lib/rspec/core/rake_task.rb', line 21 def pattern @pattern end |
#rcov ⇒ Object
Use rcov for code coverage?
default:
false
68 69 70 |
# File 'lib/rspec/core/rake_task.rb', line 68 def rcov @rcov end |
#rcov_opts ⇒ Object
Command line options to pass to rcov.
default:
nil
80 81 82 |
# File 'lib/rspec/core/rake_task.rb', line 80 def rcov_opts @rcov_opts end |
#rcov_path ⇒ Object
Path to rcov.
default:
'rcov'
74 75 76 |
# File 'lib/rspec/core/rake_task.rb', line 74 def rcov_path @rcov_path end |
#rspec_opts ⇒ Object
Command line options to pass to rspec.
default:
nil
98 99 100 |
# File 'lib/rspec/core/rake_task.rb', line 98 def rspec_opts @rspec_opts end |
#rspec_path ⇒ Object
Path to rspec
default:
'rspec'
92 93 94 |
# File 'lib/rspec/core/rake_task.rb', line 92 def rspec_path @rspec_path end |
#ruby_opts ⇒ Object
Command line options to pass to ruby.
default:
nil
86 87 88 |
# File 'lib/rspec/core/rake_task.rb', line 86 def ruby_opts @ruby_opts end |
#verbose ⇒ Object
Use verbose output. If this is set to true, the task will print the executed spec command to stdout.
default:
true
62 63 64 |
# File 'lib/rspec/core/rake_task.rb', line 62 def verbose @verbose end |
Instance Method Details
#gemfile= ⇒ Object
Has no effect. The rake task now checks ENV instead.
31 32 33 |
# File 'lib/rspec/core/rake_task.rb', line 31 def gemfile=(*) RSpec.deprecate("RSpec::Core::RakeTask#gemfile=", 'ENV["BUNDLE_GEMFILE"]') end |
#skip_bundler= ⇒ Object
Has no effect. The rake task now checks ENV instead.
25 26 27 |
# File 'lib/rspec/core/rake_task.rb', line 25 def skip_bundler=(*) RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=") end |
#spec_opts=(opts) ⇒ Object
Use rspec_opts instead.
Command line options to pass to rspec.
default:
nil
107 108 109 110 |
# File 'lib/rspec/core/rake_task.rb', line 107 def spec_opts=(opts) RSpec.deprecate('RSpec::Core::RakeTask#spec_opts=', 'rspec_opts=') @rspec_opts = opts end |
#warning=(true_or_false) ⇒ Object
Use ruby_opts=“-w” instead.
When true, requests that the specs be run with the warning flag set. e.g. “ruby -w”
default:
false
43 44 45 46 |
# File 'lib/rspec/core/rake_task.rb', line 43 def warning=(true_or_false) RSpec.deprecate("RSpec::Core::RakeTask#warning=", 'ruby_opts="-w"') @warning = true_or_false end |