Class: SpecifyHtmlReport
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- SpecifyHtmlReport
- Defined in:
- lib/specify_html_reporter.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DEFAULT_REPORT_PATH =
File.join( '.', 'reports', Time.now.strftime('%Y%m%d-%H%M%S') )
- REPORT_PATH =
ENV['REPORT_PATH'] || DEFAULT_REPORT_PATH
- SCREEN_GRAB_PATH =
File.join(REPORT_PATH, 'screen_grabs')
- VIDEO_RECORD_PATH =
File.join(REPORT_PATH, 'video_records')
Instance Method Summary collapse
- #close(_notification) ⇒ Object
- #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
-
#initialize(_output) ⇒ SpecifyHtmlReport
constructor
A new instance of SpecifyHtmlReport.
Constructor Details
#initialize(_output) ⇒ SpecifyHtmlReport
Returns a new instance of SpecifyHtmlReport.
22 23 24 25 26 27 28 29 30 |
# File 'lib/specify_html_reporter.rb', line 22 def initialize(_output) create_report_directory create_screen_grabs_directory create_video_records_directory provide_report_resources @group_collection = {} @group_level = 0 end |
Instance Method Details
#close(_notification) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/specify_html_reporter.rb', line 81 def close(_notification) File.open("#{REPORT_PATH}/overview.html", "w") do |f| @overview = @group_collection overview_results overview_durations @total_examples = @passed + @failed + @pending overview_file = File.read( File.dirname(__FILE__) + "/../templates/overview.erb" ) f.puts ERB.new(overview_file).result(binding) end end |
#example_failed(notification) ⇒ Object
71 72 73 74 |
# File 'lib/specify_html_reporter.rb', line 71 def example_failed(notification) @group_example_failure_count += 1 @examples << Example.new(notification.example) end |
#example_group_finished(notification) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/specify_html_reporter.rb', line 44 def example_group_finished(notification) @group_level -= 1 return unless @group_level.zero? group_file = notification.group.description.parameterize @title = notification.group.description File.open("#{REPORT_PATH}/#{group_file}.html", "w") do |f| construct_report_file(notification) report_file = File.read( File.dirname(__FILE__) + "/../templates/report.erb" ) f.puts ERB.new(report_file).result(binding) end end |
#example_group_started(_notification) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/specify_html_reporter.rb', line 32 def example_group_started(_notification) return unless @group_level.zero? @examples = [] @group_example_count = 0 @group_example_success_count = 0 @group_example_failure_count = 0 @group_example_pending_count = 0 @group_level += 1 end |
#example_passed(notification) ⇒ Object
66 67 68 69 |
# File 'lib/specify_html_reporter.rb', line 66 def example_passed(notification) @group_example_success_count += 1 @examples << Example.new(notification.example) end |
#example_pending(notification) ⇒ Object
76 77 78 79 |
# File 'lib/specify_html_reporter.rb', line 76 def example_pending(notification) @group_example_pending_count += 1 @examples << Example.new(notification.example) end |
#example_started(_notification) ⇒ Object
62 63 64 |
# File 'lib/specify_html_reporter.rb', line 62 def example_started(_notification) @group_example_count += 1 end |