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
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
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) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(*args) ⇒ Formatter
23 24 25 26 |
# File 'lib/rspec_api_docs/formatter.rb', line 23 def initialize(*args) @resources = {} super args end |
Instance Attribute Details
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
21 22 23 |
# File 'lib/rspec_api_docs/formatter.rb', line 21 def resources @resources end |
Instance Method Details
#close(null_notification) ⇒ void
This method returns an undefined value.
Calls the configured renderer with the stored Resources.
42 43 44 |
# File 'lib/rspec_api_docs/formatter.rb', line 42 def close(null_notification) renderer.new(resources.values.sort_by { |resource| [resource.precedence, resource.name].join }).render end |
#example_passed(example_notification) ⇒ void
This method returns an undefined value.
Initializes and stores Resources.
31 32 33 34 35 36 37 |
# File 'lib/rspec_api_docs/formatter.rb', line 31 def example_passed(example_notification) rspec_example = example_notification.example return unless rspec_example.[METADATA_NAMESPACE] resource = Resource.new(rspec_example) resources[resource.name] ||= resource resources[resource.name].add_example Resource::Example.new(rspec_example) end |