From 605045214f6f8aca3d4eee36ae812d26f5467bba Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sat, 17 Aug 2024 08:21:40 +0300 Subject: [PATCH] #111 basics --- Gemfile | 8 ++++-- Gemfile.lock | 27 ++++++++++++++++++-- test/pages/test_vitals.rb | 39 +++++++++++++++++++++++++++++ test/test__helper.rb | 52 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 test/pages/test_vitals.rb create mode 100644 test/test__helper.rb diff --git a/Gemfile b/Gemfile index 6c0140d..21811e5 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,10 @@ source 'http://rubygems.org' gem 'fbe', '>0' gem 'judges', '>0' -gem 'rake', '13.2.1' +gem 'minitest', '5.25.1', require: false +gem 'minitest-reporters', '1.7.1', require: false +gem 'rake', '13.2.1', require: false gem 'redcarpet', '~>3.5' -gem 'rubocop', '1.65.1' +gem 'rubocop', '1.65.1', require: false +gem 'w3c_validators', '1.3.7', require: false +gem 'webmock', '3.23.1', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 1dbc38f..b56bec8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,7 @@ GEM tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) + ansi (1.5.0) ast (2.4.2) backtrace (0.4.0) base64 (0.2.0) @@ -29,8 +30,12 @@ GEM tago (~> 0) typhoeus (~> 1.3) bigdecimal (3.1.8) + builder (3.3.0) concurrent-ruby (1.3.4) connection_pool (2.4.1) + crack (1.0.0) + bigdecimal + rexml decoor (0.0.1) drb (2.2.1) ethon (0.16.0) @@ -88,6 +93,7 @@ GEM graphql-client (0.23.0) activesupport (>= 3.0) graphql (>= 1.13.0) + hashdiff (1.1.1) i18n (1.14.5) concurrent-ruby (~> 1.0) iri (0.8.0) @@ -109,7 +115,12 @@ GEM language_server-protocol (3.17.0.3) logger (1.6.0) loog (0.6.0) - minitest (5.25.0) + minitest (5.25.1) + minitest-reporters (1.7.1) + ansi + builder + minitest (>= 5.0) + ruby-progressbar moments (0.3.0) multipart-post (2.4.1) net-http (0.4.1) @@ -131,7 +142,7 @@ GEM faraday (>= 1, < 3) sawyer (~> 0.9) others (0.0.3) - parallel (1.26.2) + parallel (1.26.3) parser (3.3.4.2) ast (~> 2.4.1) racc @@ -173,6 +184,14 @@ GEM verbose (0.0.2) loog (~> 0.2) tago (~> 0.0) + w3c_validators (1.3.7) + json (>= 1.8) + nokogiri (~> 1.6) + rexml (~> 3.2) + webmock (3.23.1) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) yaml (0.3.0) PLATFORMS @@ -194,9 +213,13 @@ PLATFORMS DEPENDENCIES fbe (> 0) judges (> 0) + minitest (= 5.25.1) + minitest-reporters (= 1.7.1) rake (= 13.2.1) redcarpet (~> 3.5) rubocop (= 1.65.1) + w3c_validators (= 1.3.7) + webmock (= 3.23.1) BUNDLED WITH 2.5.16 diff --git a/test/pages/test_vitals.rb b/test/pages/test_vitals.rb new file mode 100644 index 0000000..a8eda48 --- /dev/null +++ b/test/pages/test_vitals.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +require 'minitest/autorun' +require 'webmock/minitest' +require 'nokogiri' +require 'w3c_validators' + +# Test. +# Author:: Yegor Bugayenko (yegor256@gmail.com) +# Copyright:: Copyright (c) 2024 Yegor Bugayenko +# License:: MIT +class TestVitals < Minitest::Test + def test_validate_html + WebMock.enable_net_connect! + puts 1 + end +end diff --git a/test/test__helper.rb b/test/test__helper.rb new file mode 100644 index 0000000..ce29fef --- /dev/null +++ b/test/test__helper.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +ENV['RACK_ENV'] = 'test' + +require 'simplecov' +SimpleCov.start + +require 'simplecov-cobertura' +SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter + +require 'minitest/reporters' +Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new] + +require 'minitest/autorun' + +class Minitest::Test + def load_it(judge, fb) + $fb = fb + $global = {} + $local = {} + $judge = judge + $options = Judges::Options.new({ 'repositories' => 'foo/foo' }) + $loog = Loog::NULL + load(File.join(__dir__, "../judges/#{judge}/#{judge}.rb")) + end + + def stub_github(url, body:, method: :get, status: 200, headers: { 'content-type': 'application/json' }) + stub_request(method, url).to_return(status:, body: body.to_json, headers:) + end +end