Sha256: 63ea31a69a812295a8521e966f65c35a33aa6222442be12a447accb3750de0f4

Contents?: true

Size: 938 Bytes

Versions: 5

Compression:

Stored size: 938 Bytes

Contents

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

module Reek
  module Spec
    #
    # An rspec matcher that matches when the +actual+ has the specified
    # code smell and no others.
    #
    # @api private
    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 = 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

5 entries across 5 versions & 1 rubygems

Version Path
reek-3.0.4 lib/reek/spec/should_reek_only_of.rb
reek-3.0.3 lib/reek/spec/should_reek_only_of.rb
reek-3.0.2 lib/reek/spec/should_reek_only_of.rb
reek-3.0.1 lib/reek/spec/should_reek_only_of.rb
reek-3.0.0 lib/reek/spec/should_reek_only_of.rb