Class: AllureRSpec::Formatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/allure-rspec/formatter.rb

Constant Summary collapse

ALLOWED_LABELS =
[:feature, :story, :severity, :language, :framework]

Instance Method Summary collapse

Instance Method Details

#example_failed(example) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/allure-rspec/formatter.rb', line 10

def example_failed(example)
  AllureRubyAdaptorApi::Builder.stop_test(
      example.[:example_group][:description_args].first,
      example.[:description],
      example.[:execution_result].merge(
          :caller => example.[:caller],
          :exception => example.[:execution_result][:exception]
      )
  )
  super
end

#example_group_finished(group) ⇒ Object



22
23
24
25
# File 'lib/allure-rspec/formatter.rb', line 22

def example_group_finished(group)
  AllureRubyAdaptorApi::Builder.stop_suite(group.[:example_group][:description_args].first)
  super
end

#example_group_started(group) ⇒ Object



27
28
29
30
# File 'lib/allure-rspec/formatter.rb', line 27

def example_group_started(group)
  AllureRubyAdaptorApi::Builder.start_suite(group.[:example_group][:description_args].first, labels(group))
  super
end

#example_passed(example) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/allure-rspec/formatter.rb', line 32

def example_passed(example)
  AllureRubyAdaptorApi::Builder.stop_test(
      example.[:example_group][:description_args].first,
      example.[:description],
      example.[:execution_result].merge(:caller => example.[:caller])
  )
  super
end

#example_pending(example) ⇒ Object



41
42
43
# File 'lib/allure-rspec/formatter.rb', line 41

def example_pending(example)
  super
end

#example_started(example) ⇒ Object



45
46
47
48
49
50
# File 'lib/allure-rspec/formatter.rb', line 45

def example_started(example)
  suite = example.[:example_group][:description_args].first
  test = example.[:description]
  AllureRubyAdaptorApi::Builder.start_test(suite, test, labels(example))
  super
end

#start(example_count) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/allure-rspec/formatter.rb', line 52

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)
  super
end

#stopObject



62
63
64
65
# File 'lib/allure-rspec/formatter.rb', line 62

def stop
  AllureRubyAdaptorApi::Builder.build!
  super
end