Class: Rubyzen::Collections::RaisesCollection

Inherits:
BaseCollection show all
Defined in:
lib/rubyzen/collections/raises_collection.rb

Overview

Collection of raise declarations found in methods or classes.

Examples:

Ensuring no plain-string raises in controllers

expect(controllers.raises.with_string).to zen_empty

Instance Method Summary collapse

Methods inherited from BaseCollection

#filter

Instance Method Details

#with_exception_type(exception_class) ⇒ RaisesCollection

Filters raises that include the given exception class.

Parameters:

  • exception_class (String)

    the exception class name to match

Returns:



19
20
21
22
23
# File 'lib/rubyzen/collections/raises_collection.rb', line 19

def with_exception_type(exception_class)
  filter do |raise_declaration|
    raise_declaration.exception_types.include?(exception_class)
  end
end

#with_stringRaisesCollection

Filters raises that use a plain string message (not an exception class).

Returns:



11
12
13
# File 'lib/rubyzen/collections/raises_collection.rb', line 11

def with_string
  filter(&:with_string?)
end