Sha256: e786e98f74ddfaf11459ebcbe0e514fe22f1a2ce690ca34268e9c4753d4cdbb4
Contents?: true
Size: 1.22 KB
Versions: 9
Compression:
Stored size: 1.22 KB
Contents
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'examiner') require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'cli', 'report') module Reek module Spec # # An rspec matcher that matches when the +actual+ has the specified # code smell and no others. # class ShouldReekOnlyOf < ShouldReekOf # :nodoc: def matches?(actual) matches_examiner?(Examiner.new(actual)) end def matches_examiner?(examiner) @examiner = examiner @warnings = @examiner.smells @warnings.length == 1 and @warnings[0].matches?(@klass, @patterns) end def failure_message_for_should rpt = Cli::ReportFormatter.format_list(@warnings) "Expected #{@examiner.description} to reek only of #{@klass}, but got:\n#{rpt}" end def failure_message_for_should_not "Expected #{@examiner.description} not to reek only of #{@klass}, but it did" end end # # As for reek_of, but the matched smell warning must be the only warning of # any kind in the target source code's Reek report. # def reek_only_of(smell_class, *patterns) ShouldReekOnlyOf.new(smell_class, patterns) end end end
Version data entries
9 entries across 9 versions & 1 rubygems