Sha256: d93120763b0e1347277bd5e3b1c38ff3f6e6e009e0429864a694a8942fc04995

Contents?: true

Size: 854 Bytes

Versions: 8

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

require_relative '../examiner'
require_relative '../report/formatter'

module Reek
  module Spec
    #
    # An rspec matcher that matches when the +actual+ has code smells.
    #
    class ShouldReek
      def initialize(configuration: Configuration::AppConfiguration.default)
        @configuration = configuration
      end

      def matches?(source)
        self.examiner = Examiner.new(source, configuration: configuration)
        examiner.smelly?
      end

      def failure_message
        "Expected #{examiner.description} to reek, but it didn't"
      end

      def failure_message_when_negated
        rpt = Report::Formatter.format_list(examiner.smells)
        "Expected no smells, but got:\n#{rpt}"
      end

      private

      attr_reader :configuration
      attr_accessor :examiner
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reek-4.8.2 lib/reek/spec/should_reek.rb
reek-4.8.1 lib/reek/spec/should_reek.rb
reek-4.8.0 lib/reek/spec/should_reek.rb
reek-4.7.3 lib/reek/spec/should_reek.rb
reek-4.7.2 lib/reek/spec/should_reek.rb
reek-4.7.1 lib/reek/spec/should_reek.rb
reek-4.7.0 lib/reek/spec/should_reek.rb
reek-4.6.2 lib/reek/spec/should_reek.rb