Add rspec world preserve hack
This commit is contained in:
parent
8d18f7c9cd
commit
8c3cc4a18c
2 changed files with 24 additions and 0 deletions
|
@ -40,6 +40,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def run_rspec
|
||||
strategy.prepare_world
|
||||
::RSpec::Core::Runner.run(command_line_arguments, @error_stream, @output_stream)
|
||||
end
|
||||
|
||||
|
|
|
@ -29,6 +29,29 @@ module Mutant
|
|||
end
|
||||
|
||||
class Rspec < self
|
||||
|
||||
def self.original_world
|
||||
@original_world ||=
|
||||
begin
|
||||
require './spec/spec_helper'
|
||||
::RSpec.world
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepare_world
|
||||
::RSpec.instance_variable_set(:@world, original_world)
|
||||
cleanup_world
|
||||
end
|
||||
|
||||
def self.cleanup_world
|
||||
::RSpec::Core::ExampleGroup.children.clear
|
||||
::RSpec::Core::ExampleGroup.constants.each do |name|
|
||||
if name =~ /^Nested/
|
||||
RSpec::Core::ExampleGroup.send(:remove_const, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
KILLER = Killer::Rspec
|
||||
|
||||
class DM2 < self
|
||||
|
|
Loading…
Add table
Reference in a new issue