diff --git a/lib/mutant/subject.rb b/lib/mutant/subject.rb index f92ccb64..54e61d3f 100644 --- a/lib/mutant/subject.rb +++ b/lib/mutant/subject.rb @@ -9,11 +9,11 @@ module Mutant # @return [Enumerable] # @return [undefined] def mutations - mutations = [neutral_mutation] - Mutator.each(node) do |mutant| - mutations << Mutation::Evil.new(self, wrap_node(mutant)) - end - mutations + [neutral_mutation].concat( + Mutator.each(node).map do |mutant| + Mutation::Evil.new(self, wrap_node(mutant)) + end + ) end memoize :mutations diff --git a/lib/mutant/subject/method/instance.rb b/lib/mutant/subject/method/instance.rb index 347bc4f6..9a991579 100644 --- a/lib/mutant/subject/method/instance.rb +++ b/lib/mutant/subject/method/instance.rb @@ -24,8 +24,7 @@ module Mutant # @return [self] def prepare scope.__send__(:memoized_methods).instance_variable_get(:@memory).delete(name) - super - self + super() end private diff --git a/spec/unit/mutant/subject/method/instance_spec.rb b/spec/unit/mutant/subject/method/instance_spec.rb index e32d0157..005bfd8b 100644 --- a/spec/unit/mutant/subject/method/instance_spec.rb +++ b/spec/unit/mutant/subject/method/instance_spec.rb @@ -103,7 +103,7 @@ RSpec.describe Mutant::Subject::Method::Instance::Memoized do it_should_behave_like 'a command method' end - describe '#mutations' do + describe '#mutations', mutant_expression: 'Mutant::Subject#mutations' do subject { object.mutations } let(:expected) do diff --git a/spec/unit/mutant/subject_spec.rb b/spec/unit/mutant/subject_spec.rb index 6000bfe0..d13c6ccb 100644 --- a/spec/unit/mutant/subject_spec.rb +++ b/spec/unit/mutant/subject_spec.rb @@ -71,7 +71,7 @@ RSpec.describe Mutant::Subject do subject { object.mutations } before do - expect(Mutant::Mutator).to receive(:each).with(node).and_yield(mutation_a).and_yield(mutation_b) + expect(Mutant::Mutator).to receive(:each).with(node).and_return([mutation_a, mutation_b]) end let(:mutation_a) { double('Mutation A') }