Class: Selenium::RSpec::Reporting::FilePathStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/rspec/reporting/file_path_strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(final_report_file_path) ⇒ FilePathStrategy

Returns a new instance of FilePathStrategy.



7
8
9
10
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 7

def initialize(final_report_file_path)
  @final_report_file_path = final_report_file_path
  @relative_dir = nil
end

Instance Method Details

#base_report_dirObject



12
13
14
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 12

def base_report_dir
  @base_report_dir ||= File.dirname(File.expand_path(@final_report_file_path))
end

#example_hash(example) ⇒ Object



62
63
64
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 62

def example_hash(example)
  Digest::MD5.hexdigest example.implementation_backtrace.first
end

#file_path(relative_file_path) ⇒ Object



55
56
57
58
59
60
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 55

def file_path(relative_file_path)
  the_file_path = base_report_dir + "/" + relative_file_path
  parent_dir = File.dirname(the_file_path)
  FileUtils.mkdir_p(parent_dir) unless File.directory?(parent_dir)
  the_file_path
end

#file_path_for_html_capture(example) ⇒ Object



39
40
41
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 39

def file_path_for_html_capture(example)
  file_path relative_file_path_for_html_capture(example)
end

#file_path_for_page_screenshot(example) ⇒ Object



47
48
49
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 47

def file_path_for_page_screenshot(example)
  file_path relative_file_path_for_page_screenshot(example)
end

#file_path_for_remote_control_logs(example) ⇒ Object



51
52
53
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 51

def file_path_for_remote_control_logs(example)
  file_path relative_file_path_for_remote_control_logs(example)
end

#file_path_for_system_screenshot(example) ⇒ Object



43
44
45
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 43

def file_path_for_system_screenshot(example)
  file_path relative_file_path_for_system_screenshot(example)
end

#relative_dirObject



16
17
18
19
20
21
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 16

def relative_dir
  return @relative_dir if @relative_dir
  
  file_name_without_extension = File.basename(@final_report_file_path).sub(/\.[^\.]*$/, "")
  @relative_dir ||=  "resources/" + file_name_without_extension
end

#relative_file_path_for_html_capture(example) ⇒ Object



23
24
25
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 23

def relative_file_path_for_html_capture(example)
  "#{relative_dir}/example_#{example_hash(example)}.html"
end

#relative_file_path_for_page_screenshot(example) ⇒ Object



31
32
33
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 31

def relative_file_path_for_page_screenshot(example)
  "#{relative_dir}/example_#{example_hash(example)}_page_screenshot.png"
end

#relative_file_path_for_remote_control_logs(example) ⇒ Object



35
36
37
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 35

def relative_file_path_for_remote_control_logs(example)
  "#{relative_dir}/example_#{example_hash(example)}_remote_control.log"
end

#relative_file_path_for_system_screenshot(example) ⇒ Object



27
28
29
# File 'lib/selenium/rspec/reporting/file_path_strategy.rb', line 27

def relative_file_path_for_system_screenshot(example)
  "#{relative_dir}/example_#{example_hash(example)}_system_screenshot.png"
end