Sha256: 67ea8cc6cbe6f2732cdcaed93d007984817101cb5f7f5a4b9ff616484749a2aa

Contents?: true

Size: 876 Bytes

Versions: 2

Compression:

Stored size: 876 Bytes

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 code smells.
    #
    class ShouldReek        # :nodoc:
      def matches?(actual)
        @examiner = Examiner.new(actual)
        @examiner.smelly?
      end
      def failure_message_for_should
        "Expected #{@examiner.description} to reek, but it didn't"
      end
      def failure_message_for_should_not
        "Expected no smells, but got:\n#{list_smells(@examiner)}"
      end
      def list_smells(examiner)
        examiner.all_active_smells.map do |smell|
          "#{smell.report('%c %w (%s)')}"
        end.join("\n")
      end
    end

    #
    # Returns +true+ if and only if the target source code contains smells.
    #
    def reek
      ShouldReek.new
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-1.2.7.1 lib/reek/spec/should_reek.rb
reek-1.2.7 lib/reek/spec/should_reek.rb