Class: RspecApiDocs::Formatter
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- RspecApiDocs::Formatter
- Defined in:
- lib/rspec_api_docs/formatter.rb
Overview
The RSpec formatter.
Usage:
rspec --format=RspecApiDocs::Formatter
Instance Attribute Summary collapse
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#close(null_notification) ⇒ void
Calls the configured renderer with the stored Resources.
-
#example_passed(example_notification) ⇒ void
Initializes and stores Resources.
-
#initialize(*args, renderer: default_renderer) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(*args, renderer: default_renderer) ⇒ Formatter
Returns a new instance of Formatter.
24 25 26 27 |
# File 'lib/rspec_api_docs/formatter.rb', line 24 def initialize(*args, renderer: default_renderer) @renderer = renderer super args end |
Instance Attribute Details
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
22 23 24 |
# File 'lib/rspec_api_docs/formatter.rb', line 22 def renderer @renderer end |
Instance Method Details
#close(null_notification) ⇒ void
This method returns an undefined value.
Calls the configured renderer with the stored Resources.
41 42 43 |
# File 'lib/rspec_api_docs/formatter.rb', line 41 def close(null_notification) renderer.new(resource_collection.all).render end |
#example_passed(example_notification) ⇒ void
This method returns an undefined value.
Initializes and stores Resources.
32 33 34 35 36 |
# File 'lib/rspec_api_docs/formatter.rb', line 32 def example_passed(example_notification) rspec_example = example_notification.example return unless rspec_example.[METADATA_NAMESPACE] resource_collection.add_example(rspec_example) end |