Module: AppThwack::Reports
- Defined in:
- lib/ruby_appthwack/reports.rb
Class Method Summary collapse
-
.convert_reports(reports, platform = 'android') ⇒ Object
Converts Android reports into results readable by Cucumber plugin.
- .extract_reports(reports) ⇒ Object
Class Method Details
.convert_reports(reports, platform = 'android') ⇒ Object
Converts Android reports into results readable by Cucumber plugin. You should pass in the folder locatino of the reports
16 17 18 19 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 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ruby_appthwack/reports.rb', line 16 def convert_reports(reports, platform='android') # default to android folder intermediate_folders = 'calabash_tests_from_features.zip' dst = 'cucumber-html-reports' # unless platform is explicitly ios if platform.eql? 'ios' intermediate_folders = 'calabash' end folders = Dir["#{reports}/*"] # extract for each of the devices folders.each do |f| # capitalize every word device = f.gsub('_', ' ').split.map(&:capitalize).join(' ') report = File.join(f, intermediate_folders, 'raw_calabash_json_output.instrtxt') if File.exists? report features = [] # now we just add the device prefix to each feature name to make it unique File.open(report, 'r') do |io| features = JSON.load(io) if not features.nil? features.each_index do |i| # append the device name to the feature name features[i]['name'] = "#{features[i]['name']} on #{device}" end end Dir.mkdir dst if not Dir.exists? dst # original folder name folder_name = f.sub(reports + "/", '') # now write out the new file File.open(File.join(dst, "#{Time.now.to_i}_#{folder_name}.json"), 'w') do |io| JSON.dump(features, io) unless features.nil? end end end end dst end |
.extract_reports(reports) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/ruby_appthwack/reports.rb', line 7 def extract_reports(reports) # make new folder name by chopping off .zip file out = reports.sub('.zip', '') # unzip then return the new folder name out if system "rm -rf #{out} && unzip -qq #{reports} -d #{out}" end |