From 98ed4b7206b2b9e3eaf35dfe8b1d6823d4cdf5f8 Mon Sep 17 00:00:00 2001 From: Sorokin Maksim <60688343+askonev@users.noreply.github.com> Date: Fri, 8 Dec 2023 10:38:38 +0300 Subject: [PATCH] revert: TestData (#1009) --- .rubocop_todo.yml | 8 ++--- lib/doc_builder_static_data.rb | 29 +++++++++++++++++++ lib/doc_builder_testing.rb | 1 + spec/doc_builder_wrapper_spec.rb | 2 +- spec/docx/smoke/api_style_spec.rb | 2 +- spec/spec_helper.rb | 4 +-- ...oc_builder_static_data.rb => test_data.rb} | 28 +----------------- spec/xlsx/smoke/api_range_spec.rb | 4 +-- 8 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 lib/doc_builder_static_data.rb rename spec/{doc_builder_static_data.rb => test_data.rb} (60%) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5d0eb56ba..9d7c1df6e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,17 +1,17 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-11-28 10:56:01 UTC using RuboCop version 1.57.2. +# on 2023-12-05 12:17:16 UTC using RuboCop version 1.58.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 4 +# Offense count: 3 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 21 + Max: 16 -# Offense count: 121 +# Offense count: 126 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 21 diff --git a/lib/doc_builder_static_data.rb b/lib/doc_builder_static_data.rb new file mode 100644 index 000000000..9a41139e8 --- /dev/null +++ b/lib/doc_builder_static_data.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +# module for doc builder static data +module DocBuilderStaticData + # Default style list in the CDE + DEFAULT_STYLES = [ + 'Normal', + 'No Spacing', + 'Heading 1', + 'Heading 2', + 'Heading 3', + 'Heading 4', + 'Heading 5', + 'Heading 6', + 'Heading 7', + 'Heading 8', + 'Heading 9', + 'Title', + 'Subtitle', + 'Quote', + 'Intense Quote', + 'List Paragraph', + 'Caption', + 'Header', + 'Footer', + 'Footnote text', + 'Endnote text' + ].freeze +end diff --git a/lib/doc_builder_testing.rb b/lib/doc_builder_testing.rb index 5ef35c7b8..c591236da 100644 --- a/lib/doc_builder_testing.rb +++ b/lib/doc_builder_testing.rb @@ -3,6 +3,7 @@ require 'tempfile' require 'ooxml_parser' require 'onlyoffice_pdf_parser' +require_relative 'doc_builder_static_data' require_relative 'doc_builder_testing/exceptions' require_relative 'doc_builder_testing/doc_builder_wrapper' require_relative 'doc_builder_testing/web_doc_builder_wrapper' diff --git a/spec/doc_builder_wrapper_spec.rb b/spec/doc_builder_wrapper_spec.rb index 09fa8332b..05d46e005 100644 --- a/spec/doc_builder_wrapper_spec.rb +++ b/spec/doc_builder_wrapper_spec.rb @@ -87,7 +87,7 @@ end describe 'check windows build libs', :win do - DocBuilderStaticData.libs.each do |lib| + TestData.libs.each do |lib| it lib.to_s do skip('[WIN] check build libs') unless Gem.win_platform? expect(arr_libs).to include(lib) diff --git a/spec/docx/smoke/api_style_spec.rb b/spec/docx/smoke/api_style_spec.rb index f2117e0a2..a2941de08 100644 --- a/spec/docx/smoke/api_style_spec.rb +++ b/spec/docx/smoke/api_style_spec.rb @@ -89,7 +89,7 @@ it 'ApiStyle | ToJSON method' do docx = builder.build_and_parse('js/docx/smoke/api_style/to_json.js') json = JSON.parse(docx.elements[22].nonempty_runs[0].text) - DocBuilderStaticData.cde_styles.each_with_index do |style, index| + DocBuilderStaticData::DEFAULT_STYLES.each_with_index do |style, index| # TODO: To understand why incorrect names are recorded next if (style == 'Header') || # in the metadata: Custom_Style 719 styleId: 42 (style == 'Footer') || # in the metadata: Custom_Style 725 styleId: 44 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 03d4ab1e6..6733b25ab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true Encoding.default_external = Encoding::UTF_8 -require 'bundler/setup' require 'rspec' +require 'test_data' +require 'bundler/setup' require_relative '../lib/doc_builder_testing' -require_relative 'doc_builder_static_data' # Get either DocBuilder of WebDocBuilder # depending of env var diff --git a/spec/doc_builder_static_data.rb b/spec/test_data.rb similarity index 60% rename from spec/doc_builder_static_data.rb rename to spec/test_data.rb index 3bcacc02b..f32ba3e74 100644 --- a/spec/doc_builder_static_data.rb +++ b/spec/test_data.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Test data for autotest -module DocBuilderStaticData +module TestData # CDE number formats (7.4.0) # @return [Array] def self.number_formats @@ -18,32 +18,6 @@ def self.number_formats '0.00E+00'].freeze end - # Default style list for CDE v7.4.1 - # @return [Array] - def self.cde_styles - ['Normal', - 'No Spacing', - 'Heading 1', - 'Heading 2', - 'Heading 3', - 'Heading 4', - 'Heading 5', - 'Heading 6', - 'Heading 7', - 'Heading 8', - 'Heading 9', - 'Title', - 'Subtitle', - 'Quote', - 'Intense Quote', - 'List Paragraph', - 'Caption', - 'Header', - 'Footer', - 'Footnote text', - 'Endnote text'].freeze - end - # @return [Array] def self.libs %w[DjVuFile.dll diff --git a/spec/xlsx/smoke/api_range_spec.rb b/spec/xlsx/smoke/api_range_spec.rb index 322837a66..423053c49 100644 --- a/spec/xlsx/smoke/api_range_spec.rb +++ b/spec/xlsx/smoke/api_range_spec.rb @@ -79,7 +79,7 @@ it 'ApiRange | NumberFormat method' do xlsx = builder.build_and_parse('js/xlsx/smoke/api_range/setter_number_format.js') - DocBuilderStaticData.number_formats.each_with_index do |format, i| + TestData.number_formats.each_with_index do |format, i| expect(xlsx.worksheets.first.rows[i + 1].cells[0].raw_text).to eq('123456') expect(xlsx.worksheets.first.rows[i + 1].cells[0].style.numerical_format).to eq(format) end @@ -88,7 +88,7 @@ it 'ApiRange | GetNumberFormat' do xlsx = builder.build_and_parse('js/xlsx/smoke/api_range/get_number_format.js') - DocBuilderStaticData.number_formats.each_with_index do |format, i| + TestData.number_formats.each_with_index do |format, i| expect(xlsx.worksheets.first.rows[i + 1].cells[2].raw_text).to eq('123456') expect(xlsx.worksheets.first.rows[i + 1].cells[2].style.numerical_format).to eq(format) end