Class: RSpecRedo::RakeTask

Inherits:
RSpec::Core::RakeTask
  • Object
show all
Defined in:
lib/rspec-redo/rake_task.rb

Constant Summary collapse

RSPEC_REDO_PATH =
File.expand_path('../../../bin/rspec-redo', __FILE__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = 'spec:redo', *args, &block) ⇒ RakeTask

Returns a new instance of RakeTask.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rspec-redo/rake_task.rb', line 9

def initialize(name = 'spec:redo', *args, &block)
  @retry_count = ENV['RETRY_COUNT']

  unless ::Rake.application.last_description
    desc 'Run RSpec code examples with RSpecRedo'
  end

  super(name, :retry_count, *args) do |t, opts|
    @retry_count = opts.retry_count
    yield self if block_given?
  end
end

Instance Attribute Details

#retry_countObject

Returns the value of attribute retry_count.



7
8
9
# File 'lib/rspec-redo/rake_task.rb', line 7

def retry_count
  @retry_count
end

Instance Method Details

#rspec_optsObject

Include the retry_count if it’s provided



30
31
32
33
# File 'lib/rspec-redo/rake_task.rb', line 30

def rspec_opts
  return super unless retry_count
  [*super, '--retry-count', retry_count]
end

#rspec_pathObject

Swap out RSpec for the Redo CLI



24
25
26
# File 'lib/rspec-redo/rake_task.rb', line 24

def rspec_path
  RSPEC_REDO_PATH
end