Sha256: 2e9af9e505843d678b2601e50ea5396bef5d1cecb3344a6e0ad5363a2a8d7968
Contents?: true
Size: 1.08 KB
Versions: 10
Compression:
Stored size: 1.08 KB
Contents
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'examiner') module Reek module Spec # # An rspec matcher that matches when the +actual+ has the specified # code smell. # class ShouldReekOf # :nodoc: def initialize(klass, patterns) @klass = klass @patterns = patterns end def matches?(actual) @examiner = Examiner.new(actual) @all_smells = @examiner.smells @all_smells.any? {|warning| warning.matches?(@klass, @patterns)} end def failure_message_for_should "Expected #{@examiner.description} to reek of #{@klass}, but it didn't" end def failure_message_for_should_not "Expected #{@examiner.description} not to reek of #{@klass}, but it did" end end # # Checks the target source code for instances of +smell_class+, # and returns +true+ only if one of them has a report string matching # all of the +patterns+. # def reek_of(smell_class, *patterns) ShouldReekOf.new(smell_class, patterns) end end end
Version data entries
10 entries across 10 versions & 1 rubygems