Module: Hubbado::Log::Logger::Substitute
- Defined in:
- lib/hubbado/log/logger/substitute.rb
Overview
What a logger was told rather than what it wrote. Extended onto a mimic of Logger, so a class under test is handed something that answers as a logger and keeps what it was given.
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
-
#logged(severity = nil, message: nil, tags: nil) ⇒ Object
Everything about what a class said, in order, narrowed by whichever criteria a spec names.
-
#logged? ⇒ Boolean
Whether, where the two above ask what.
-
#messages ⇒ Object
What a class said, where #logged is everything about it.
Instance Method Details
#logged(severity = nil, message: nil, tags: nil) ⇒ Object
Everything about what a class said, in order, narrowed by whichever criteria a spec names. Named together, because a run writes several lines and a message and a tag list asserted apart can each be true of a different one.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hubbado/log/logger/substitute.rb', line 28 def logged(severity = nil, message: nil, tags: nil) entries = invocations.map { |invocation| entry(invocation) } named = symbols() entries = entries.select { |entry| entry.at?(severity) } unless severity.nil? entries = entries.select { |entry| entry.says?() } unless .nil? entries = entries.select { |entry| entry.tagged?(named) } unless .nil? entries end |
#logged? ⇒ Boolean
Whether, where the two above ask what. Named nothing, whether anything was written.
44 |
# File 'lib/hubbado/log/logger/substitute.rb', line 44 def logged?(...) = !logged(...).empty? |
#messages ⇒ Object
What a class said, where #logged is everything about it.
41 |
# File 'lib/hubbado/log/logger/substitute.rb', line 41 def (...) = logged(...).map(&:message) |