Module: Helpers
- Included in:
- RspecPrettyHtmlReporter
- Defined in:
- lib/rspec_pretty_html_reporter/helpers.rb
Class Method Summary collapse
-
.rename_duplicate_description(group_name, description) ⇒ String
Appends a number to a duplicate description to avoid them being overwritten by Specs with the same description.
-
.rename_duplicate_filename(filename) ⇒ String
Appends a number to duplicate filename to avoid them being overwritten by Specs with the same description.
-
.theme(name) ⇒ String
Allows the theme to be changed in the report template variable is not specified when running the tests.
Class Method Details
.rename_duplicate_description(group_name, description) ⇒ String
Appends a number to a duplicate description to avoid them being overwritten by Specs with the same description.
Renames duplicate descriptions for specs that have the same description
31 32 33 34 35 36 37 |
# File 'lib/rspec_pretty_html_reporter/helpers.rb', line 31 def self.rename_duplicate_description(group_name, description) if group_name.key?(description) number = group_name.select { |k, _v| k.include?(description) }.length description = "#{description}-#{number + 1}" end description end |
.rename_duplicate_filename(filename) ⇒ String
Appends a number to duplicate filename to avoid them being overwritten by Specs with the same description.
Renames duplicate filenames for specs that have the same description
13 14 15 16 17 18 19 20 |
# File 'lib/rspec_pretty_html_reporter/helpers.rb', line 13 def self.rename_duplicate_filename(filename) if File.exist?(filename) base, ext = /\A(.+?)(\.[^.]+)?\Z/.match(filename).to_a[1..] number = 2 number += 1 while File.exist?(filename = "#{base}-#{number}#{ext}") end filename end |
.theme(name) ⇒ String
Allows the theme to be changed in the report template variable is not specified when running the tests
45 46 47 48 49 50 51 52 53 |
# File 'lib/rspec_pretty_html_reporter/helpers.rb', line 45 def self.theme(name) name = name.downcase unless name.nil? case name when 'cerulean', 'litera', 'materia', 'sketchy', 'spacelab' name else 'yeti' end end |