Reconnect API changes for successful spec run

Sorry this looks like spiking around and yeah it was some kind of.
This commit is contained in:
Markus Schirp 2013-01-21 23:54:25 +01:00
parent 7dfb785ed3
commit 5b3d506523
12 changed files with 79 additions and 44 deletions

View file

@ -76,6 +76,16 @@ module Mutant
name_nesting.last
end
# Return name
#
# @return [String]
#
# @api private
#
def name
scope.name
end
# Return scope wrapped by context
#
# @return [::Module|::Class]
@ -105,17 +115,7 @@ module Mutant
# @api private
#
def root_ast
"#{keyword} #{qualified_name}; end".to_ast
end
# Return qualified name of scope
#
# @return [String]
#
# @api private
#
def qualified_name
scope.name
"#{keyword} #{name}; end".to_ast
end
# Return nesting of names of scope

View file

@ -10,16 +10,16 @@ module Mutant
# Run rspec test
#
# @return [true]
# returns true when test is NOT successful and the mutant was killed
# when test is NOT successful and the mutant was killed
#
# @return [false]
# returns false otherwise
# otherwise
#
# @api private
#
def run
mutation.insert
!::RSpec::Core::Runner.run(command_line_arguments, strategy.error_stream, strategy.output_stream).zero?
!!::RSpec::Core::Runner.run(command_line_arguments, strategy.error_stream, strategy.output_stream).nonzero?
end
memoize :run

View file

@ -58,7 +58,7 @@ module Mutant
#
# @api private
#
def subject(subject)
def subject(_subject)
stats.count_subject
self
end
@ -71,7 +71,7 @@ module Mutant
#
# @api private
#
def mutation(mutation)
def mutation(_mutation)
self
end
@ -85,7 +85,6 @@ module Mutant
#
def report_killer(killer)
stats.count_killer(killer)
self
end

View file

@ -67,7 +67,7 @@ module Mutant
self
end
# Report config
# Report start
#
# @param [Mutant::Config] config
#
@ -75,13 +75,24 @@ module Mutant
#
# @api private
#
def print_config
def start(config)
message = []
message << 'Mutant configuration:'
message << "Matcher: #{config.matcher.inspect}"
message << "Filter: #{config.filter.inspect}"
message << "Strategy: #{config.strategy.inspect}"
puts message.join("\n")
super
end
# Report stop
#
# @return [self]
#
# @api private
#
def stop
super
end
# Report killer

View file

@ -68,7 +68,7 @@ module Mutant
# @api private
#
def run
reporter.print_config
reporter.start(config)
util = strategy
util.setup
config.matcher.each do |subject|
@ -76,7 +76,7 @@ module Mutant
run_subject(subject)
end
util.teardown
reporter.print_stats
reporter.stop
end
# Run mutation killers on subject

View file

@ -6,12 +6,14 @@ module Mutant
# Return filename pattern
#
# @param [Subject] subject
#
# @return [Enumerable<String>]
#
# @api private
#
def spec_files(mutation)
ExampleLookup.run(mutation)
def spec_files(subject)
Lookup.run(subject)
end
end

View file

@ -42,7 +42,7 @@ module Mutant
# @api private
#
def self.run(subject)
new(subject).spec_files
build(subject).spec_files
end
REGISTRY = {}

View file

@ -25,7 +25,7 @@ module Mutant
# @api private
#
def base_path
"spec/unit/#{Inflector.underscore(subject.context_name)}"
"spec/unit/#{Inflector.underscore(subject.context.name)}"
end
# Return method name
@ -35,7 +35,7 @@ module Mutant
# @api private
#
def method_name
subject.method_name
subject.name
end
# Test if method is public
@ -58,7 +58,7 @@ module Mutant
# @api private
#
def expanded_name
MethodExpansion.run(subject.method_name)
MethodExpansion.run(method_name)
end
# Return glob expression

View file

@ -15,6 +15,28 @@ module Mutant
#
abstract_method :public?
# Return method name
#
# @return [Symbol]
#
# @api private
#
def name
node.name
end
private
# Return scope
#
# @return [Class, Module]
#
# @api private
#
def scope
context.scope
end
# Instance method subjects
class Instance < self
@ -29,7 +51,7 @@ module Mutant
# @api private
#
def public?
scope.public_method_defined?(method_name)
scope.public_method_defined?(name)
end
memoize :public?
@ -42,7 +64,7 @@ module Mutant
# @api private
#
def subtype
"#{context.identification}##{node.name}"
"#{context.identification}##{name}"
end
end
@ -61,7 +83,7 @@ module Mutant
# @api private
#
def public?
scope.singleton_class.public_method_defined?(method_name)
scope.singleton_class.public_method_defined?(name)
end
memoize :public?

View file

@ -6,7 +6,7 @@ describe Mutant::CLI, '.run' do
let(:object) { described_class }
let(:argv) { mock('ARGV') }
let(:attributes) { mock('Options') }
let(:runner) { mock('Runner', :fail? => failure) }
let(:runner) { mock('Runner', :success? => success) }
let(:instance) { mock(described_class.name, :attributes => attributes) }
before do
@ -14,8 +14,8 @@ describe Mutant::CLI, '.run' do
Mutant::Runner.stub(:run => runner)
end
context 'when runner does NOT fail' do
let(:failure) { false }
context 'when runner is successful' do
let(:success) { true }
it { should be(0) }
@ -26,7 +26,7 @@ describe Mutant::CLI, '.run' do
end
context 'when runner fails' do
let(:failure) { true }
let(:success) { false }
it { should be(1) }
@ -35,4 +35,5 @@ describe Mutant::CLI, '.run' do
should be(1)
end
end
end

View file

@ -3,11 +3,11 @@ require 'spec_helper'
describe Mutant::Strategy::Rspec::DM2::Lookup::Method::Instance, '#spec_files' do
subject { object.spec_files }
let(:object) { described_class.new(mutation_subject) }
let(:mutation_subject) { mock('Subject', :method_name => method_name, :public? => is_public, :context_name => context_name) }
let(:context_name) { 'Foo' }
let(:method_name) { :bar }
let(:files) { 'Files'.freeze }
let(:object) { described_class.new(mutation_subject) }
let(:mutation_subject) { mock('Subject', :name => method_name, :public? => is_public, :context => context) }
let(:context) { mock('Context', :name => 'Foo') }
let(:method_name) { :bar }
let(:files) { 'Files'.freeze }
this_example_group = 'Mutant::Strategy::Rspec::DM2::Lookup::Method::Instance#spec_files'

View file

@ -4,11 +4,11 @@ describe Mutant::Strategy::Rspec::DM2::Lookup::Method::Singleton, '#spec_files'
subject { object.spec_files }
let(:object) { described_class.new(mutation_subject) }
let(:mutation_subject) { mock('Subject', :method_name => method_name, :public? => is_public, :context_name => context_name) }
let(:context_name) { 'Foo' }
let(:method_name) { :bar }
let(:files) { 'Files'.freeze }
let(:object) { described_class.new(mutation_subject) }
let(:mutation_subject) { mock('Subject', :name => method_name, :public? => is_public, :context => context) }
let(:method_name) { :bar }
let(:files) { 'Files'.freeze }
let(:context) { mock('Context', :name => 'Foo') }
this_example_group = 'Mutant::Strategy::Rspec::DM2::Lookup::Method::Singleton#spec_files'