Class: Mutant::Integration::Rspec
- Inherits:
-
Mutant::Integration
- Object
- Mutant::Integration
- Mutant::Integration::Rspec
- Includes:
- AbstractType
- Defined in:
- lib/mutant/integration/rspec.rb
Overview
Shared parts of rspec2/3 integration
Defined Under Namespace
Constant Summary collapse
- RSPEC_2_VERSION_PREFIX =
'2.'.freeze
Class Method Summary collapse
-
.build ⇒ Integration
private
Return integration compatible to currently loaded rspec.
Instance Method Summary collapse
-
#all_tests ⇒ Enumerable<Test>
private
Return all available tests.
-
#run(test) ⇒ Test::Result
private
Return report for test.
-
#setup ⇒ self
private
Setup rspec integration.
Class Method Details
.build ⇒ Integration
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 integration compatible to currently loaded rspec
20 21 22 23 24 25 26 |
# File 'lib/mutant/integration/rspec.rb', line 20 def self.build if RSpec::Core::Version::STRING.start_with?(RSPEC_2_VERSION_PREFIX) Rspec2.new else Rspec3.new end end |
Instance Method Details
#all_tests ⇒ Enumerable<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
79 80 81 82 83 84 85 |
# File 'lib/mutant/integration/rspec.rb', line 79 def all_tests example_group_index.keys.each_with_object([]) do |full_description, aggregate| expression = Expression.try_parse(full_description) or next aggregate << Test.new(self, expression) end end |
#run(test) ⇒ Test::Result
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
rubocop:disable MethodLength
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mutant/integration/rspec.rb', line 51 def run(test) output = StringIO.new failed = false start = Time.now reporter = new_reporter(output) reporter.report(1) do example_group_index.fetch(test.expression.syntax).each do |example_group| next if example_group.run(reporter) failed = true break end end output.rewind Result::Test.new( test: nil, mutation: nil, output: output.read, runtime: Time.now - start, passed: !failed ) end |
#setup ⇒ self
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 integration
34 35 36 37 38 |
# File 'lib/mutant/integration/rspec.rb', line 34 def setup .configure(configuration) configuration.load_spec_files self end |