Class: AllureRspec::RSpecFormatter
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- AllureRspec::RSpecFormatter
- Includes:
- Utils
- Defined in:
- lib/allure_rspec/formatter.rb
Overview
Main rspec formatter class translating rspec events to allure lifecycle
Constant Summary collapse
- ALLURE_STATUS =
Returns allure statuses mapping.
{ failed: Allure::Status::FAILED, pending: Allure::Status::SKIPPED, passed: Allure::Status::PASSED }.freeze
Instance Method Summary collapse
-
#example_finished(example_notification) ⇒ void
Finishes example.
-
#example_group_finished(_example_group_notification) ⇒ void
Starts example group.
-
#example_group_started(example_group_notification) ⇒ void
Starts example group.
-
#example_started(example_notification) ⇒ void
Starts example.
-
#initialize(output) ⇒ RSpecFormatter
constructor
A new instance of RSpecFormatter.
-
#start(_start_notification) ⇒ void
Start test run.
-
#stop(_stop_notification) ⇒ void
Start test run.
Methods included from Utils
Constructor Details
#initialize(output) ⇒ RSpecFormatter
Returns a new instance of RSpecFormatter.
37 38 39 40 41 42 |
# File 'lib/allure_rspec/formatter.rb', line 37 def initialize(output) super @allure_config = AllureRspec.configuration Allure.lifecycle = @lifecycle = Allure::AllureLifecycle.new(@allure_config) end |
Instance Method Details
#example_finished(example_notification) ⇒ void
This method returns an undefined value.
Finishes example
83 84 85 86 |
# File 'lib/allure_rspec/formatter.rb', line 83 def example_finished(example_notification) lifecycle.update_test_case(&update_test_proc(example_notification.example.execution_result)) lifecycle.stop_test_case end |
#example_group_finished(_example_group_notification) ⇒ void
This method returns an undefined value.
Starts example group
91 92 93 |
# File 'lib/allure_rspec/formatter.rb', line 91 def example_group_finished(_example_group_notification) lifecycle.stop_test_container end |
#example_group_started(example_group_notification) ⇒ void
This method returns an undefined value.
Starts example group
66 67 68 69 70 71 |
# File 'lib/allure_rspec/formatter.rb', line 66 def example_group_started(example_group_notification) description = example_group_notification.group.description.then do |desc| desc.empty? ? "Anonymous" : desc end lifecycle.start_test_container(Allure::TestResultContainer.new(name: description)) end |
#example_started(example_notification) ⇒ void
This method returns an undefined value.
Starts example
76 77 78 |
# File 'lib/allure_rspec/formatter.rb', line 76 def example_started(example_notification) lifecycle.start_test_case(test_result(example_notification.example)) end |
#start(_start_notification) ⇒ void
This method returns an undefined value.
Start test run
47 48 49 50 51 52 53 54 |
# File 'lib/allure_rspec/formatter.rb', line 47 def start(_start_notification) lifecycle.clean_results_dir lifecycle.write_categories RSpec::Core::Example.class_eval do include Allure end end |
#stop(_stop_notification) ⇒ void
This method returns an undefined value.
Start test run
59 60 61 |
# File 'lib/allure_rspec/formatter.rb', line 59 def stop(_stop_notification) lifecycle.write_environment end |