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]
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
12 13 14 15 16 |
# File 'lib/allure-rspec/formatter.rb', line 12 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
18 19 20 |
# File 'lib/allure-rspec/formatter.rb', line 18 def example_group_finished(notification) AllureRubyAdaptorApi::Builder.stop_suite(description(notification.group).to_s) end |
#example_group_started(notification) ⇒ Object
22 23 24 |
# File 'lib/allure-rspec/formatter.rb', line 22 def example_group_started(notification) AllureRubyAdaptorApi::Builder.start_suite(description(notification.group).to_s, labels(notification)) end |
#example_passed(notification) ⇒ Object
26 27 28 |
# File 'lib/allure-rspec/formatter.rb', line 26 def example_passed(notification) stop_test(notification.example) end |
#example_pending(notification) ⇒ Object
30 31 32 |
# File 'lib/allure-rspec/formatter.rb', line 30 def example_pending(notification) stop_test(notification.example) end |
#example_started(notification) ⇒ Object
34 35 36 37 38 |
# File 'lib/allure-rspec/formatter.rb', line 34 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
40 41 42 43 44 45 46 47 |
# File 'lib/allure-rspec/formatter.rb', line 40 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
49 50 51 |
# File 'lib/allure-rspec/formatter.rb', line 49 def stop(notify) AllureRubyAdaptorApi::Builder.build! end |