Class: RSpec::Rails::Swagger::Formatter
- Inherits:
-
Core::Formatters::BaseTextFormatter
- Object
- Core::Formatters::BaseTextFormatter
- RSpec::Rails::Swagger::Formatter
- Defined in:
- lib/rspec/rails/swagger/formatter.rb
Instance Method Summary collapse
- #close(_notification) ⇒ Object
- #documents ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_finished(notification) ⇒ Object
- #example_group_started(notification) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
Instance Method Details
#close(_notification) ⇒ Object
46 47 48 49 50 |
# File 'lib/rspec/rails/swagger/formatter.rb', line 46 def close(_notification) documents.each{|k, v| write_json(k, v)} self end |
#documents ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rspec/rails/swagger/formatter.rb', line 12 def documents # We don't try to load the docs in `initalize` because when running # `rspec -f RSpec::Swagger::Formatter` RSpec initalized this class # before `swagger_helper` has run. @documents ||= ::RSpec.configuration.swagger_docs end |
#example_failed(notification) ⇒ Object
31 32 33 |
# File 'lib/rspec/rails/swagger/formatter.rb', line 31 def example_failed(notification) output.print RSpec::Core::Formatters::ConsoleCodes.wrap(example_output(notification), :failure) end |
#example_finished(notification) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rspec/rails/swagger/formatter.rb', line 35 def example_finished(notification) = notification.example. return unless [:swagger_object] == :response # Then add everything to the document document = document_for([:swagger_document]) path_item = path_item_for(document, [:swagger_path_item]) operation = operation_for(path_item, [:swagger_operation]) response = response_for(operation, [:swagger_response]) end |
#example_group_started(notification) ⇒ Object
19 20 21 |
# File 'lib/rspec/rails/swagger/formatter.rb', line 19 def example_group_started(notification) output.print *group_output(notification) end |
#example_passed(notification) ⇒ Object
23 24 25 |
# File 'lib/rspec/rails/swagger/formatter.rb', line 23 def example_passed(notification) output.print RSpec::Core::Formatters::ConsoleCodes.wrap(example_output(notification), :success) end |
#example_pending(notification) ⇒ Object
27 28 29 |
# File 'lib/rspec/rails/swagger/formatter.rb', line 27 def example_pending(notification) output.print RSpec::Core::Formatters::ConsoleCodes.wrap(example_output(notification), :pending) end |