Class: Mutant::Rspec::Strategy

Inherits:
Strategy
  • Object
show all
Defined in:
lib/mutant/rspec/strategy.rb

Overview

Rspec killer strategy

Constant Summary collapse

RSPEC_2_VERSION_PREFIX =
'2.'.freeze

Instance Method Summary collapse

Instance Method Details

#all_testsEnumerable<Test>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return all available tests

Returns:

  • (Enumerable<Test>)


61
62
63
64
65
66
67
68
69
# File 'lib/mutant/rspec/strategy.rb', line 61

def all_tests
  example_groups
    .flat_map(&:descendants)
    .map do |example_group|
      Test.new(self, example_group)
    end.select do |test|
      test.identification.split(' ', 2).first.eql?(test.identification)
    end
end

#rspec2?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for rspec2

Returns:

  • (Boolean)


30
31
32
# File 'lib/mutant/rspec/strategy.rb', line 30

def rspec2?
  RSpec::Core::Version::STRING.start_with?(RSPEC_2_VERSION_PREFIX)
end

#run(test) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return report for test

Parameters:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mutant/rspec/strategy.rb', line 40

def run(test)
  output = StringIO.new
  success = false
  reporter = new_reporter(output)
  reporter.report(1) do
    success = test.example_group.run(reporter)
  end
  output.rewind
  Test::Report.new(
    test:    self,
    output:  output.read,
    success: success
  )
end

#setupself

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Setup rspec strategy

Returns:

  • (self)


17
18
19
20
21
# File 'lib/mutant/rspec/strategy.rb', line 17

def setup
  options.configure(configuration)
  configuration.load_spec_files
  self
end