Sha256: e092d0af9b1b4b9ecc1af7f8677d4121225cb7d3b6716237b99ef97c143bc50c
Contents?: true
Size: 1.2 KB
Versions: 5
Compression:
Stored size: 1.2 KB
Contents
require_relative '../examiner' module Reek module Spec # # An rspec matcher that matches when the +actual+ has the specified # code smell. # # @api private class ShouldReekOf def initialize(smell_category, smell_details = {}) @smell_category = normalize smell_category @smell_details = smell_details end def matches?(actual) @examiner = Examiner.new(actual) @all_smells = @examiner.smells @all_smells.any? { |warning| warning.matches?(@smell_category, @smell_details) } end def failure_message "Expected #{@examiner.description} to reek of #{@smell_category}, but it didn't" end def failure_message_when_negated "Expected #{@examiner.description} not to reek of #{@smell_category}, but it did" end private def normalize(smell_category_or_type) # In theory, users can give us many different types of input (see the documentation for # reek_of below), however we're basically ignoring all of those subleties and just # return a string with the prepending namespace stripped. smell_category_or_type.to_s.split(/::/)[-1] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems