diff --git a/lib/mutant.rb b/lib/mutant.rb index fccb8010..82982a4b 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -12,6 +12,7 @@ require 'ice_nine' require 'ice_nine/core_ext/object' require 'diff/lcs' require 'diff/lcs/hunk' +require 'rspec' # Library namespace module Mutant diff --git a/lib/mutant/killer/forking.rb b/lib/mutant/killer/forking.rb index 7c598dde..95e43710 100644 --- a/lib/mutant/killer/forking.rb +++ b/lib/mutant/killer/forking.rb @@ -1,38 +1,39 @@ module Mutant class Killer -# class Forked < self -# def initialize(killer, mutation) -# @killer = killer -# super(mutation) -# end + class Forked < self + def initialize(killer, mutation) + @killer = killer + super(mutation) + end -# def type -# @killer.type -# end + def type + @killer.type + end -# def run -# fork do -# @killer.new(@mutation) -# end + def run + fork do + @killer.new(@mutation) + end -# status = Process.wait2.last -# status.exitstatus.zero? -# end -# end + status = Process.wait2.last + status.exitstatus.zero? + end + end -# class Forking < self -# include Equalizer.new(:killer) + class Forking < self + include Equalizer.new(:killer) -# attr_reader :killer + attr_reader :killer -# def initialize(strategy) -# @killer = killer -# end + def initialize(strategy) + @killer = killer + end + + def new(mutation) + Forked.new(@killer, mutation) + end + end -# def run(mutation) -# Forked.new(@killer, mutation) -# end -# end end end diff --git a/lib/mutant/killer/rspec.rb b/lib/mutant/killer/rspec.rb index eea11ec5..32c3cca4 100644 --- a/lib/mutant/killer/rspec.rb +++ b/lib/mutant/killer/rspec.rb @@ -62,12 +62,7 @@ module Mutant # @api private # def run_rspec - require 'rspec' self.class.nest do - require './spec/spec_helper.rb' - if RSpec.world.shared_example_groups.empty? - Dir['spec/{support,shared}/**/*.rb'].each { |f| load(f) } - end ::RSpec::Core::Runner.run(command_line_arguments, @error_stream, @output_stream) end end diff --git a/lib/mutant/strategy.rb b/lib/mutant/strategy.rb index a7ae5b7f..6f968131 100644 --- a/lib/mutant/strategy.rb +++ b/lib/mutant/strategy.rb @@ -15,7 +15,7 @@ module Mutant end def self.killer - self::KILLER + Killer::Forking.new(self::KILLER) end class Rspec < self diff --git a/mutant b/mutant index 0779a7c5..1fc4e310 100755 --- a/mutant +++ b/mutant @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require 'mutant' -require 'mutant/cli' namespace = if File.basename($0) == 'zombie' diff --git a/mutant.gemspec b/mutant.gemspec index a5dde508..bd787523 100644 --- a/mutant.gemspec +++ b/mutant.gemspec @@ -13,6 +13,7 @@ Gem::Specification.new do |gem| gem.files = `git ls-files`.split("\n") gem.test_files = `git ls-files -- spec`.split("\n") gem.extra_rdoc_files = %w[TODO] + gem.executable = [ 'mutant' ] gem.add_runtime_dependency('to_source', '~> 0.1.3') gem.add_runtime_dependency('ice_nine', '~> 0.5.0')