Sha256: de2d8f120875fcd5af83fc61273e00e23339d344de9a7bd6e5b44663db02e5be

Contents?: true

Size: 886 Bytes

Versions: 31

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

require_relative '../examiner'
require_relative '../report/simple_warning_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::SimpleWarningFormatter.new.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

31 entries across 29 versions & 2 rubygems

Version Path
reek-6.4.0 lib/reek/spec/should_reek.rb
reek-6.3.0 lib/reek/spec/should_reek.rb
reek-6.2.0 lib/reek/spec/should_reek.rb
reek-6.1.4 lib/reek/spec/should_reek.rb
reek-6.1.3 lib/reek/spec/should_reek.rb
reek-6.1.2 lib/reek/spec/should_reek.rb
reek-6.1.1 lib/reek/spec/should_reek.rb
reek-6.1.0 lib/reek/spec/should_reek.rb
reek-6.0.6 lib/reek/spec/should_reek.rb
reek-6.0.5 lib/reek/spec/should_reek.rb
reek-6.0.4 lib/reek/spec/should_reek.rb
reek-6.0.3 lib/reek/spec/should_reek.rb
reek-6.0.2 lib/reek/spec/should_reek.rb
reek-6.0.1 lib/reek/spec/should_reek.rb
reek-6.0.0 lib/reek/spec/should_reek.rb
reek-5.6.0 lib/reek/spec/should_reek.rb
reek-5.5.0 lib/reek/spec/should_reek.rb
reek-5.4.1 lib/reek/spec/should_reek.rb
reek-5.4.0 lib/reek/spec/should_reek.rb
reek-5.3.2 lib/reek/spec/should_reek.rb