Introduce Mutant::Config objects
This will ease deve
This commit is contained in:
parent
1114a156e5
commit
c7fae6dd07
8 changed files with 45 additions and 11 deletions
|
@ -1,5 +1,9 @@
|
|||
# v0.2.17 2013-01-20
|
||||
|
||||
* [change][dm2] Kill mutations in #initialize from class methods.
|
||||
|
||||
# v0.2.17 2013-01-20
|
||||
|
||||
* [change] Update dependencies
|
||||
|
||||
# v0.2.16 2013-01-20
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -4,5 +4,5 @@ gemspec
|
|||
|
||||
gem 'composition', :git => 'https://github.com/mbj/composition.git'
|
||||
|
||||
gem 'devtools', :git => 'https://github.com/datamapper/devtools.git'
|
||||
gem 'devtools', :path => '../devtools' #:git => 'https://github.com/datamapper/devtools.git'
|
||||
eval(File.read(File.join(File.dirname(__FILE__),'Gemfile.devtools')))
|
||||
|
|
|
@ -14,6 +14,7 @@ require 'composition'
|
|||
require 'diff/lcs'
|
||||
require 'diff/lcs/hunk'
|
||||
require 'rspec'
|
||||
require 'anima'
|
||||
|
||||
# Patch ice none to freeze nodes correctly
|
||||
class IceNine::Freezer
|
||||
|
@ -83,6 +84,7 @@ require 'mutant/mutator/node/return'
|
|||
require 'mutant/mutator/node/iter_19'
|
||||
require 'mutant/mutator/node/if'
|
||||
require 'mutant/mutator/node/receiver_case'
|
||||
require 'mutant/config'
|
||||
require 'mutant/loader'
|
||||
require 'mutant/context'
|
||||
require 'mutant/context/scope'
|
||||
|
|
|
@ -14,7 +14,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def self.run(*arguments)
|
||||
config = new(*arguments)
|
||||
config = new(*arguments).config
|
||||
runner = Runner::Config.run(config)
|
||||
runner.success? ? EXIT_SUCCESS : EXIT_FAILURE
|
||||
rescue Error => exception
|
||||
|
@ -46,6 +46,25 @@ module Mutant
|
|||
matcher
|
||||
end
|
||||
|
||||
# Return config
|
||||
#
|
||||
# @return [Config]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def config
|
||||
Config.new(
|
||||
:debug => debug?,
|
||||
:matcher => matcher,
|
||||
:filter => filter,
|
||||
:strategy => strategy,
|
||||
:reporter => reporter
|
||||
)
|
||||
end
|
||||
memoize :config
|
||||
|
||||
private
|
||||
|
||||
# Test for running in debug mode
|
||||
#
|
||||
# @return [true]
|
||||
|
@ -98,8 +117,6 @@ module Mutant
|
|||
end
|
||||
memoize :reporter
|
||||
|
||||
private
|
||||
|
||||
# Return matcher
|
||||
#
|
||||
# @return [Mutant::Matcher]
|
||||
|
|
8
lib/mutant/config.rb
Normal file
8
lib/mutant/config.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
module Mutant
|
||||
# The configuration of a mutator run
|
||||
class Config
|
||||
include Adamantium::Flat, Anima.new(
|
||||
:debug, :strategy, :matcher, :filter, :reporter
|
||||
)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
module Mutant
|
||||
class Runner
|
||||
# Runner for config
|
||||
class Config < self
|
||||
|
||||
# Return subject runners
|
||||
|
|
|
@ -25,4 +25,5 @@ Gem::Specification.new do |gem|
|
|||
gem.add_runtime_dependency('abstract_type', '~> 0.0.4')
|
||||
gem.add_runtime_dependency('rspec-core', '~> 2.13.0')
|
||||
gem.add_runtime_dependency('diff-lcs', '~> 1.2.1')
|
||||
gem.add_runtime_dependency('anima', '~> 0.0.5')
|
||||
end
|
||||
|
|
|
@ -3,11 +3,12 @@ require 'spec_helper'
|
|||
describe Mutant::CLI, '.run' do
|
||||
subject { object.run(argv) }
|
||||
|
||||
let(:object) { described_class }
|
||||
let(:argv) { mock('ARGV') }
|
||||
let(:attributes) { mock('Options') }
|
||||
let(:runner) { mock('Runner', :success? => success) }
|
||||
let(:instance) { mock(described_class.name, :attributes => attributes) }
|
||||
let(:object) { described_class }
|
||||
let(:argv) { mock('ARGV') }
|
||||
let(:attributes) { mock('Options') }
|
||||
let(:runner) { mock('Runner', :success? => success) }
|
||||
let(:config) { mock('Config') }
|
||||
let(:instance) { mock(described_class.name, :config => config) }
|
||||
|
||||
before do
|
||||
described_class.stub(:new => instance)
|
||||
|
@ -20,7 +21,7 @@ describe Mutant::CLI, '.run' do
|
|||
it { should be(0) }
|
||||
|
||||
it 'should run with attributes' do
|
||||
Mutant::Runner::Config.should_receive(:run).with(instance).and_return(runner)
|
||||
Mutant::Runner::Config.should_receive(:run).with(config).and_return(runner)
|
||||
should be(0)
|
||||
end
|
||||
end
|
||||
|
@ -31,7 +32,7 @@ describe Mutant::CLI, '.run' do
|
|||
it { should be(1) }
|
||||
|
||||
it 'should run with attributes' do
|
||||
Mutant::Runner::Config.should_receive(:run).with(instance).and_return(runner)
|
||||
Mutant::Runner::Config.should_receive(:run).with(config).and_return(runner)
|
||||
should be(1)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue