Sha256: 8767b1f5384f92ace5b04dce7fffd4dcde431645699a1c0ca932a2b0cb7e7d4b

Contents?: true

Size: 914 Bytes

Versions: 4

Compression:

Stored size: 914 Bytes

Contents

require 'reek/examiner'
require 'reek/cli/report/formatter'

module Reek
  module Spec
    #
    # An rspec matcher that matches when the +actual+ has the specified
    # code smell and no others.
    #
    class ShouldReekOnlyOf < ShouldReekOf
      def matches?(actual)
        matches_examiner?(Examiner.new(actual))
      end

      def matches_examiner?(examiner)
        @examiner = examiner
        @warnings = @examiner.smells
        return false if @warnings.empty?
        @warnings.all? { |warning| warning.matches?(@smell_category) }
      end

      def failure_message
        rpt = Cli::Report::Formatter.format_list(@warnings)
        "Expected #{@examiner.description} to reek only of #{@smell_category}, but got:\n#{rpt}"
      end

      def failure_message_when_negated
        "Expected #{@examiner.description} not to reek only of #{@smell_category}, but it did"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reek-2.0.4 lib/reek/spec/should_reek_only_of.rb
reek-2.0.3 lib/reek/spec/should_reek_only_of.rb
reek-2.0.2 lib/reek/spec/should_reek_only_of.rb
reek-2.0.1 lib/reek/spec/should_reek_only_of.rb