Class: AllureRSpec::Formatter
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- AllureRSpec::Formatter
- Defined in:
- lib/allure-rspec/formatter.rb
Constant Summary collapse
- NOTIFICATIONS =
[:example_group_started, :example_group_finished, :example_started, :example_failed, :example_passed, :example_pending, :start, :stop]
- ALLOWED_LABELS =
[:feature, :story, :severity, :language, :framework, :issue, :testId, :host, :thread]
Instance Method Summary collapse
- #example_failed(notification) ⇒ Object
- #example_group_finished(notification) ⇒ Object
- #example_group_started(notification) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
- #example_started(notification) ⇒ Object
- #start(example_count) ⇒ Object
- #stop(notify) ⇒ Object
Instance Method Details
#example_failed(notification) ⇒ Object
13 14 15 16 17 |
# File 'lib/allure-rspec/formatter.rb', line 13 def example_failed(notification) res = notification.example.execution_result status = res.exception.is_a?(RSpec::Expectations::ExpectationNotMetError) ? :failed : :broken stop_test(notification.example, :exception => res.exception, :status => status) end |
#example_group_finished(notification) ⇒ Object
19 20 21 |
# File 'lib/allure-rspec/formatter.rb', line 19 def example_group_finished(notification) AllureRubyAdaptorApi::Builder.stop_suite(description(notification.group).to_s) end |
#example_group_started(notification) ⇒ Object
23 24 25 |
# File 'lib/allure-rspec/formatter.rb', line 23 def example_group_started(notification) AllureRubyAdaptorApi::Builder.start_suite(description(notification.group).to_s, labels(notification)) end |
#example_passed(notification) ⇒ Object
27 28 29 |
# File 'lib/allure-rspec/formatter.rb', line 27 def example_passed(notification) stop_test(notification.example) end |
#example_pending(notification) ⇒ Object
31 32 33 |
# File 'lib/allure-rspec/formatter.rb', line 31 def example_pending(notification) stop_test(notification.example) end |
#example_started(notification) ⇒ Object
35 36 37 38 39 |
# File 'lib/allure-rspec/formatter.rb', line 35 def example_started(notification) suite = description(notification.example.example_group).to_s test = description(notification.example).to_s AllureRubyAdaptorApi::Builder.start_test(suite, test, labels(notification)) end |
#start(example_count) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/allure-rspec/formatter.rb', line 41 def start(example_count) dir = Pathname.new(AllureRSpec::Config.output_dir) if AllureRSpec::Config.clean_dir? puts "Cleaning output directory '#{dir}'..." FileUtils.rm_rf(dir) end FileUtils.mkdir_p(dir) end |
#stop(notify) ⇒ Object
50 51 52 |
# File 'lib/allure-rspec/formatter.rb', line 50 def stop(notify) AllureRubyAdaptorApi::Builder.build! end |