From 9568a7ac8aeb055c13ffa85efbd2711a097e904b Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Tue, 28 Jan 2025 11:44:50 +0300 Subject: [PATCH] #194 minitest check --- .rubocop.yml | 5 +++++ Gemfile | 3 +++ Gemfile.lock | 11 +++++++++++ judges/normalize-metrics/normalize-metrics.rb | 4 ++-- test/pages/test_eva_summary.rb | 4 ++-- test/pages/test_vitals.rb | 4 ++-- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b08011b..cdfe7f9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -27,7 +27,12 @@ AllCops: TargetRubyVersion: 3.2 SuggestExtensions: false NewCops: enable +require: + - rubocop-minitest + - rubocop-performance +Minitest/EmptyLineBeforeAssertionMethods: + Enabled: false Naming/FileName: Regex: '^[a-z\-._]*$' Style/GlobalVars: diff --git a/Gemfile b/Gemfile index acaf8c1..19d8462 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,9 @@ gem 'qbash', '0.3.0', require: false gem 'rake', '13.2.1', require: false gem 'redcarpet', '~>3.5' gem 'rubocop', '1.69.2', require: false +gem 'rubocop-minitest', '0.36.0', require: false +gem 'rubocop-performance', '1.23.1', require: false +gem 'rubocop-rspec', '3.4.0', require: false gem 'simplecov', '0.22.0', require: false gem 'simplecov-cobertura', '2.1.0', require: false gem 'w3c_validators', '1.3.7', require: false diff --git a/Gemfile.lock b/Gemfile.lock index e73fcd8..c0cce30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -195,6 +195,14 @@ GEM unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.38.0) parser (>= 3.3.1.0) + rubocop-minitest (0.36.0) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-performance (1.23.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (3.4.0) + rubocop (~> 1.61) ruby-progressbar (1.13.0) sawyer (0.9.2) addressable (>= 2.3.5) @@ -257,6 +265,9 @@ DEPENDENCIES rake (= 13.2.1) redcarpet (~> 3.5) rubocop (= 1.69.2) + rubocop-minitest (= 0.36.0) + rubocop-performance (= 1.23.1) + rubocop-rspec (= 3.4.0) simplecov (= 0.22.0) simplecov-cobertura (= 2.1.0) w3c_validators (= 1.3.7) diff --git a/judges/normalize-metrics/normalize-metrics.rb b/judges/normalize-metrics/normalize-metrics.rb index b556cfd..e75169f 100644 --- a/judges/normalize-metrics/normalize-metrics.rb +++ b/judges/normalize-metrics/normalize-metrics.rb @@ -34,7 +34,7 @@ def fits(name) %w[quantity-of-deliverables quality-of-service].each do |qo| facts = Fbe.fb.query("(eq what '#{qo}')").each.to_a - facts.sort! { |a, b| a.when <=> b.when } + facts.sort_by!(&:when) next if facts.empty? start = {} @@ -59,7 +59,7 @@ def fits(name) s = start[prop] diff = v - s diff /= start[prop] unless start[prop].zero? - f.send("n_#{prop}=", diff) + f.send(:"n_#{prop}=", diff) end end end diff --git a/test/pages/test_eva_summary.rb b/test/pages/test_eva_summary.rb index 98a6120..fa7eb14 100644 --- a/test/pages/test_eva_summary.rb +++ b/test/pages/test_eva_summary.rb @@ -44,7 +44,7 @@ def test_template_long ' ) - assert(!xml.xpath('/p/text()').to_s.start_with?('Not enough data'), xml) + refute(xml.xpath('/p/text()').to_s.start_with?('Not enough data')) end def test_template_short @@ -58,6 +58,6 @@ def test_template_short ' ) - assert(xml.xpath('/p/text()').to_s.start_with?('Not enough data'), xml) + assert(xml.xpath('/p/text()').to_s.start_with?('Not enough data')) end end diff --git a/test/pages/test_vitals.rb b/test/pages/test_vitals.rb index 013fd2c..de2c316 100644 --- a/test/pages/test_vitals.rb +++ b/test/pages/test_vitals.rb @@ -47,8 +47,8 @@ def test_validate_html rescue StandardError => e raise "#{doc}\n\n#{e}" end - assert(xml.errors.empty?, xml) - assert(!xml.xpath('/html').empty?, xml) + assert_empty(xml.errors, xml) + refute_empty(xml.xpath('/html'), xml) # WebMock.enable_net_connect! # v = W3CValidators::NuValidator.new.validate_file(html) # assert(v.errors.empty?, "#{doc}\n\n#{v.errors.join('; ')}")