Class: Reek::Spec::ShouldReekOf Private

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/spec/should_reek_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.

Direct Known Subclasses

ShouldReekOnlyOf

Instance Method Summary collapse

Constructor Details

#initialize(smell_category, smell_details = {}) ⇒ ShouldReekOf

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 a new instance of ShouldReekOf.



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

def initialize(smell_category, smell_details = {})
  @smell_category = normalize smell_category
  @smell_details  = smell_details
end

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.



22
23
24
# File 'lib/reek/spec/should_reek_of.rb', line 22

def failure_message
  "Expected #{@examiner.description} to reek of #{@smell_category}, but it didn't"
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.



26
27
28
# File 'lib/reek/spec/should_reek_of.rb', line 26

def failure_message_when_negated
  "Expected #{@examiner.description} not to reek 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)


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

def matches?(actual)
  @examiner = Examiner.new(actual)
  @all_smells = @examiner.smells
  @all_smells.any? { |warning| warning.matches?(@smell_category, @smell_details) }
end