Sha256: d4b45f46ddcea6c56274a27836d0aa02a2fcd5936ef820be5828d3cd297c41f8

Contents?: true

Size: 853 Bytes

Versions: 28

Compression:

Stored size: 853 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

28 entries across 28 versions & 1 rubygems

Version Path
reek-4.6.1 lib/reek/spec/should_reek.rb
reek-4.6.0 lib/reek/spec/should_reek.rb
reek-4.5.6 lib/reek/spec/should_reek.rb
reek-4.5.5 lib/reek/spec/should_reek.rb
reek-4.5.4 lib/reek/spec/should_reek.rb
reek-4.5.3 lib/reek/spec/should_reek.rb
reek-4.5.2 lib/reek/spec/should_reek.rb
reek-4.5.1 lib/reek/spec/should_reek.rb
reek-4.5.0 lib/reek/spec/should_reek.rb
reek-4.4.2 lib/reek/spec/should_reek.rb
reek-4.4.1 lib/reek/spec/should_reek.rb
reek-4.4.0 lib/reek/spec/should_reek.rb
reek-4.3.0 lib/reek/spec/should_reek.rb
reek-4.2.5 lib/reek/spec/should_reek.rb
reek-4.2.4 lib/reek/spec/should_reek.rb
reek-4.2.3 lib/reek/spec/should_reek.rb
reek-4.2.2 lib/reek/spec/should_reek.rb
reek-4.2.1 lib/reek/spec/should_reek.rb
reek-4.2.0 lib/reek/spec/should_reek.rb
reek-4.1.1 lib/reek/spec/should_reek.rb