Module: RSpec::Rerun::Tasks
- Defined in:
- lib/rspec-rerun/tasks.rb
Class Method Summary collapse
- .failed_count ⇒ Object
- .failing_specs ⇒ Object
- .failure_message ⇒ Object
- .parse_args(args) ⇒ Object
- .rerun(args) ⇒ Object
- .rspec_options(args, spec_files = nil) ⇒ Object
- .run(args) ⇒ Object
Class Method Details
.failed_count ⇒ Object
52 53 54 |
# File 'lib/rspec-rerun/tasks.rb', line 52 def failed_count failing_specs.count end |
.failing_specs ⇒ Object
48 49 50 |
# File 'lib/rspec-rerun/tasks.rb', line 48 def failing_specs File.read(RSpec::Rerun::Formatter::FILENAME).split end |
.failure_message ⇒ Object
56 57 58 |
# File 'lib/rspec-rerun/tasks.rb', line 56 def "[#{Time.now}] Failed, #{failed_count} failure#{failed_count == 1 ? '' : 's'}" end |
.parse_args(args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rspec-rerun/tasks.rb', line 22 def parse_args(args) = args.extras # Error on multiple arguments if .size > 1 fail ArgumentError 'rspec-rerun can take an integer (retry_count) or options hash' else = [0] end # Handle if opts is just a retry_count integer = if .is_a? Hash else { retry_count: } end # Parse environment variables [:pattern] ||= ENV['RSPEC_RERUN_PATTERN'] if ENV['RSPEC_RERUN_PATTERN'] [:tag] ||= ENV['RSPEC_RERUN_TAG'] if ENV['RSPEC_RERUN_TAG'] [:retry_count] ||= ENV['RSPEC_RERUN_RETRY_COUNT'] if ENV['RSPEC_RERUN_RETRY_COUNT'] [:verbose] = (ENV['RSPEC_RERUN_VERBOSE'] != 'false') if [:verbose].nil? end |
.rerun(args) ⇒ Object
64 65 66 |
# File 'lib/rspec-rerun/tasks.rb', line 64 def rerun(args) Rake::Task['rspec-rerun:rerun'].execute(args) end |
.rspec_options(args, spec_files = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rspec-rerun/tasks.rb', line 8 def (args, spec_files = nil) = [ spec_files, '--require', 'rspec-rerun/formatter', '--format', 'RSpec::Rerun::Formatter', * ].compact.flatten if args[:tag] << '--tag' << args[:tag] end end |
.run(args) ⇒ Object
60 61 62 |
# File 'lib/rspec-rerun/tasks.rb', line 60 def run(args) Rake::Task['rspec-rerun:run'].execute(args) end |