Class: Reek::Spec::ShouldReekOnlyOf Private

Inherits:
ShouldReekOf show all
Defined in:
lib/reek/spec/should_reek_only_of.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An rspec matcher that matches when the actual has the specified code smell and no others.

Instance Method Summary collapse

Methods inherited from ShouldReekOf

#initialize

Constructor Details

This class inherits a constructor from Reek::Spec::ShouldReekOf

Instance Method Details

#failure_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
# File 'lib/reek/spec/should_reek_only_of.rb', line 23

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

#failure_message_when_negatedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/reek/spec/should_reek_only_of.rb', line 28

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

#matches?(actual) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


12
13
14
# File 'lib/reek/spec/should_reek_only_of.rb', line 12

def matches?(actual)
  matches_examiner?(Examiner.new(actual))
end

#matches_examiner?(examiner) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/reek/spec/should_reek_only_of.rb', line 16

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