module GoldenRose class ClassConfigurator def initialize(source_type, folder_path, output_path) @source_type = source_type @folder_path = folder_path @output_path = output_path end def self.configure(source_type, folder_path, output_path) new(source_type, folder_path, output_path).configure end def configure add_screenshot_to_each_test end private def add_screenshot_to_each_test source_type = @source_type folder_path = @folder_path output_path = @output_path FileUtils.remove_dir(@output_path + "/screenshots", true) GoldenRose::ChildItem.class_eval do @@source_type = source_type @@folder_path = folder_path @@output_path = output_path def screenshot return @screenshot if @screenshot screenshot_item = last_activity_with_screenshot return unless screenshot_item dest_path = @@output_path + "/screenshots" FileUtils.mkdir_p dest_path source_path = "Attachments/Screenshot_#{screenshot_item[:uuid]}.png" screen = FileResource.new(:screenshoot, @@source_type, @@folder_path, source_path, "#{dest_path}/Screenshot_#{screenshot_item[:uuid]}.png") @screenshot = screen.path end end end end end