Sha256: 6fb2b53ec06e415a12b0efc66845fddb0f4fe3a84530ba49cfa9cb3da9912d39

Contents?: true

Size: 980 Bytes

Versions: 7

Compression:

Stored size: 980 Bytes

Contents

require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'examiner')
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'cli', 'report')

module Reek
  module Spec

    #
    # An rspec matcher that matches when the +actual+ has code smells.
    #
    class ShouldReek        # :nodoc:
      def initialize(config_files = [])
        @config_files = config_files
      end
      def matches?(actual)
        @examiner = Examiner.new(actual, @config_files)
        @examiner.smelly?
      end
      def failure_message_for_should
        "Expected #{@examiner.description} to reek, but it didn't"
      end
      def failure_message_for_should_not
        rpt = Cli::ReportFormatter.format_list(@examiner.smells)
        "Expected no smells, but got:\n#{rpt}"
      end
    end

    #
    # Returns +true+ if and only if the target source code contains smells.
    #
    def reek
      ShouldReek.new(Dir['config/*.reek'])
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reek-1.3.1 lib/reek/spec/should_reek.rb
reek-1.3 lib/reek/spec/should_reek.rb
reek-1.2.13 lib/reek/spec/should_reek.rb
reek-1.2.12 lib/reek/spec/should_reek.rb
reek-1.2.11 lib/reek/spec/should_reek.rb
reek-1.2.10 lib/reek/spec/should_reek.rb
reek-1.2.9 lib/reek/spec/should_reek.rb