Do not present un idempotent interface on abstract class

This commit is contained in:
Markus Schirp 2014-05-11 14:38:07 +00:00
parent cfd8ea8855
commit 82634f383c
5 changed files with 12 additions and 29 deletions

View file

@ -61,7 +61,7 @@ module Mutant
begin
data = Marshal.load(reader.read)
rescue ArgumentError => exception
rescue ArgumentError
raise IsolationError, 'Childprocess wrote unmarshallable data'
end

View file

@ -57,8 +57,9 @@ module Mutant
# @api private
#
def identification
"#{subject.identification}:#{code}"
"#{self.class::SYMBOL}:#{subject.identification}:#{code}"
end
memoize :identification
# Return mutation code
#

View file

@ -6,17 +6,7 @@ module Mutant
class Evil < self
SHOULD_FAIL = true
# Return identification
#
# @return [String]
#
# @api private
#
def identification
"evil:#{super}"
end
memoize :identification
SYMBOL = 'evil'.freeze
# Test if killer is successful
#

View file

@ -15,17 +15,6 @@ module Mutant
end # Noop
# Return identification
#
# @return [String]
#
# @api private
#
def identification
"#{self.class::SYMBOL}:#{super}"
end
memoize :identification
end # Neutral
end # Mutation
end # Mutant

View file

@ -4,8 +4,11 @@ require 'spec_helper'
describe Mutant::Mutation do
let(:class_under_test) { Class.new(described_class) { memoize :identification } }
let(:object) { class_under_test.new(mutation_subject, Mutant::NodeHelpers::N_NIL) }
class TestMutation < Mutant::Mutation
SYMBOL = 'test'
end
let(:object) { TestMutation.new(mutation_subject, Mutant::NodeHelpers::N_NIL) }
let(:mutation_subject) { double('Subject', identification: 'subject', source: 'original') }
let(:node) { double('Node') }
@ -37,7 +40,7 @@ describe Mutant::Mutation do
subject { object.identification }
it { should eql('subject:8771a') }
it { should eql('test:subject:8771a') }
it_should_behave_like 'an idempotent method'
end