Sha256: 98f3b1ce27fa95e1216263db35c257334e4d157abe89b7b070b2d67f00959cf3
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 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 = {}, configuration = Configuration::AppConfiguration.default) @smell_category = normalize smell_category @smell_details = smell_details @configuration = configuration end def matches?(actual) self.examiner = Examiner.new(actual, configuration: configuration) self.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 private_attr_reader :configuration, :smell_category, :smell_details private_attr_accessor :all_smells, :examiner 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reek-3.3.1 | lib/reek/spec/should_reek_of.rb |
reek-3.3.0 | lib/reek/spec/should_reek_of.rb |