From c8d16fdec37379296ae3645bee3bcba451cff4fe Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sun, 4 Aug 2013 19:30:34 +0200 Subject: [PATCH] Correct implementation of match_prefix es --- lib/mutant/context/scope.rb | 5 ++++- lib/mutant/subject.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mutant/context/scope.rb b/lib/mutant/context/scope.rb index 0ad28624..b06c2b34 100644 --- a/lib/mutant/context/scope.rb +++ b/lib/mutant/context/scope.rb @@ -96,7 +96,10 @@ module Mutant # @api private # def match_prefixes - name_nesting.reverse + names = name_nesting + names.length.downto(1).map do |last| + names[0...last].join('::') + end end memoize :match_prefixes diff --git a/lib/mutant/subject.rb b/lib/mutant/subject.rb index 19c62f6e..f032a24e 100644 --- a/lib/mutant/subject.rb +++ b/lib/mutant/subject.rb @@ -99,7 +99,7 @@ module Mutant # @api private # def match_prefixes - context.match_prefixes.dup << match_expression + [match_expression].concat(context.match_prefixes) end memoize :match_prefixes