Class: Reek::Spec::ShouldReekOnlyOf

Inherits:
ShouldReekOf show all
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 Method Summary collapse

Methods inherited from ShouldReekOf

#initialize

Constructor Details

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

Instance Method Details

#failure_messageObject


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

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

#failure_message_when_negatedObject


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 #{@klass}, but it did"
end

#matches?(actual) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)

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

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

#matches_examiner?(examiner) ⇒ Boolean

Returns:

  • (Boolean)

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

def matches_examiner?(examiner)
  @examiner = examiner
  @warnings = @examiner.smells
  @warnings.length == 1 && @warnings[0].matches?(@klass, @patterns)
end