Class: ReportBuilder::Builder
- Inherits:
-
Object
- Object
- ReportBuilder::Builder
- Defined in:
- lib/report_builder/builder.rb
Overview
ReportBuilder Main class
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#build_report(opts = nil) ⇒ Object
ReportBuilder Main method.
-
#default_options ⇒ Object
ReportBuilder default configuration.
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/report_builder/builder.rb', line 15 def end |
Instance Method Details
#build_report(opts = nil) ⇒ Object
ReportBuilder Main method
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/report_builder/builder.rb', line 20 def build_report(opts = nil) = self. || .marshal_dump .merge! opts if opts.is_a? Hash fail 'Error:: Invalid report_types. Use: [:json, :html]' unless [:report_types].is_a? Array [:report_types].map!(&:to_s).map!(&:upcase) [:input_path] ||= [:json_path] || Dir.pwd groups = get_groups [:input_path] json_report_path = [:json_report_path] || [:report_path] File.open(json_report_path + '.json', 'w') do |file| file.write JSON.pretty_generate(groups.size > 1 ? groups : groups.first['features']) end if [:report_types].include? 'JSON' if [:additional_css] and Pathname.new([:additional_css]).file? [:additional_css] = File.read([:additional_css]) end if [:additional_js] and Pathname.new([:additional_js]).file? [:additional_js] = File.read([:additional_js]) end html_report_path = [:html_report_path] || [:report_path] File.open(html_report_path + '.html', 'w') do |file| file.write get(groups.size > 1 ? 'group_report' : 'report').result(binding).gsub(' ', '').gsub("\n\n", '') end if [:report_types].include? 'HTML' retry_report_path = [:retry_report_path] || [:report_path] File.open(retry_report_path + '.retry', 'w') do |file| groups.each do |group| group['features'].each do |feature| if feature['status'] == 'broken' feature['elements'].each {|scenario| file.puts "#{feature['uri']}:#{scenario['line']}" if scenario['status'] == 'failed'} end end end end if [:report_types].include? 'RETRY' [json_report_path, html_report_path, retry_report_path] end |
#default_options ⇒ Object
ReportBuilder default configuration
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/report_builder/builder.rb', line 64 def OpenStruct.new(json_path: nil, input_path: nil, report_types: [:html], report_title: 'Test Results', include_images: true, additional_info: {}, report_path: 'test_report', json_report_path: nil, html_report_path: nil, retry_report_path: nil, additional_css: nil, additional_js: nil ) end |