Class: Reek::Spec::ShouldReekOnlyOf
- Inherits:
-
ShouldReekOf
- Object
- ShouldReekOf
- Reek::Spec::ShouldReekOnlyOf
- Defined in:
- lib/reek/spec/should_reek_only_of.rb
Overview
An rspec matcher that matches when the actual
has the specified code smell and no others.
Instance Attribute Summary collapse
-
#warnings ⇒ Object
private
Returns the value of attribute warnings.
Attributes inherited from ShouldReekOf
#configuration, #examiner, #smell_details, #smell_type
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #matches?(source) ⇒ Boolean
- #matches_examiner?(examiner) ⇒ Boolean
Methods inherited from ShouldReekOf
#all_relevant_smell_details_formatted, #initialize, #matching_smell_details?, #matching_smell_types, #matching_smell_types?, #origin, #set_failure_messages, #set_failure_messages_for_smell_details, #set_failure_messages_for_smell_type, #with_config
Constructor Details
This class inherits a constructor from Reek::Spec::ShouldReekOf
Instance Attribute Details
#warnings ⇒ Object (private)
Returns the value of attribute warnings.
38 39 40 |
# File 'lib/reek/spec/should_reek_only_of.rb', line 38 def warnings @warnings end |
Instance Method Details
#failure_message ⇒ Object
27 28 29 30 |
# File 'lib/reek/spec/should_reek_only_of.rb', line 27 def rpt = Report::SimpleWarningFormatter.new.format_list(warnings) "Expected #{examiner.origin} to reek only of #{smell_type}, but got:\n#{rpt}" end |
#failure_message_when_negated ⇒ Object
32 33 34 |
# File 'lib/reek/spec/should_reek_only_of.rb', line 32 def "Expected #{examiner.origin} not to reek only of #{smell_type}, but it did" end |
#matches?(source) ⇒ Boolean
15 16 17 |
# File 'lib/reek/spec/should_reek_only_of.rb', line 15 def matches?(source) matches_examiner?(Examiner.new(source, configuration: configuration)) end |
#matches_examiner?(examiner) ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/reek/spec/should_reek_only_of.rb', line 19 def matches_examiner?(examiner) self.examiner = examiner self.warnings = examiner.smells return false if warnings.empty? warnings.all? { |warning| SmellMatcher.new(warning).matches?(smell_type) } end |