Class: Allure::FileWriter
- Inherits:
-
Object
- Object
- Allure::FileWriter
- Includes:
- JsonHelper
- Defined in:
- lib/allure_ruby_commons/file_writer.rb
Overview
Allure result file writer
Constant Summary collapse
- TEST_RESULT_SUFFIX =
Returns test result suffix.
"-result.json"
- TEST_RESULT_CONTAINER_SUFFIX =
Returns test result container suffix.
"-container.json"
- ATTACHMENT_FILE_SUFFIX =
Returns attachment file suffix.
"-attachment"
- ENVIRONMENT_FILE =
Returns environment info file.
"environment.properties"
- CATEGORIES_FILE =
Returns categories definition json.
"categories.json"
Constants included from JsonHelper
Instance Method Summary collapse
-
#initialize(results_directory) ⇒ FileWriter
constructor
File writer instance.
-
#write_attachment(source, attachment) ⇒ void
Write allure attachment file.
-
#write_categories(categories) ⇒ void
Write categories info.
-
#write_environment(environment) ⇒ void
Write allure report environment info.
-
#write_test_result(test_result) ⇒ void
Write test result.
-
#write_test_result_container(test_container_result) ⇒ void
Write test result container.
Methods included from JsonHelper
#dump_json, #json_parse_error, #load_json
Constructor Details
#initialize(results_directory) ⇒ FileWriter
File writer instance
22 23 24 |
# File 'lib/allure_ruby_commons/file_writer.rb', line 22 def initialize(results_directory) @results_directory = results_directory end |
Instance Method Details
#write_attachment(source, attachment) ⇒ void
This method returns an undefined value.
Write allure attachment file
44 45 46 |
# File 'lib/allure_ruby_commons/file_writer.rb', line 44 def (source, ) source.is_a?(File) ? copy(source.path, .source) : write(.source, source) end |
#write_categories(categories) ⇒ void
This method returns an undefined value.
Write categories info
60 61 62 63 64 65 66 |
# File 'lib/allure_ruby_commons/file_writer.rb', line 60 def write_categories(categories) if categories.is_a?(File) copy(categories.path, CATEGORIES_FILE) else write(CATEGORIES_FILE, dump_json(categories.map(&:to_hash))) end end |
#write_environment(environment) ⇒ void
This method returns an undefined value.
Write allure report environment info
51 52 53 54 55 |
# File 'lib/allure_ruby_commons/file_writer.rb', line 51 def write_environment(environment) environment.reduce("") { |e, (k, v)| e + "#{k}=#{v}\n" }.tap do |env| write(ENVIRONMENT_FILE, env) end end |
#write_test_result(test_result) ⇒ void
This method returns an undefined value.
Write test result
29 30 31 |
# File 'lib/allure_ruby_commons/file_writer.rb', line 29 def write_test_result(test_result) write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}", dump_json(test_result)) end |
#write_test_result_container(test_container_result) ⇒ void
This method returns an undefined value.
Write test result container
36 37 38 |
# File 'lib/allure_ruby_commons/file_writer.rb', line 36 def write_test_result_container(test_container_result) write("#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}", dump_json(test_container_result)) end |