Sha256: f8c46dc67ef2e591a2de3fb9af12cad5d24e4d7330bf51c92ec7bc4102153090
Contents?: true
Size: 1.1 KB
Versions: 7
Compression:
Stored size: 1.1 KB
Contents
require 'reek/examiner' require 'reek/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
7 entries across 7 versions & 1 rubygems