diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d14d0f..5b95d17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: script/install_linux_deps - name: Install MacOS packages - if: ${{ matrix.os == 'macos-11.0' }} + if: ${{ matrix.os == 'macos-latest' }} run: script/install_macos_deps - name: Set up Ruby ${{ matrix.ruby-version }} diff --git a/.rubocop.yml b/.rubocop.yml index 81748ee..2ae5ba2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,3 +2,7 @@ inherit_gem: rubocop-standard: - config/default.yml - config/minitest.yml + +AllCops: + Exclude: + - 'ext/mathematical/mtex2MML/**/*' diff --git a/Rakefile b/Rakefile index 991cac5..53c10a0 100644 --- a/Rakefile +++ b/Rakefile @@ -29,7 +29,7 @@ Rake::Task[:test].prerequisites task build: [:clean] Rake::Task[:clean].enhance do - Dir.chdir(LASEM_DIR) { puts %x(git clean -fdx); } + Dir.chdir(LASEM_DIR) { puts %x(git clean -fdx) } end desc "Copy samples to gh-pages" diff --git a/lib/mathematical/configuration.rb b/lib/mathematical/configuration.rb index 53ceb8d..e4e1cac 100644 --- a/lib/mathematical/configuration.rb +++ b/lib/mathematical/configuration.rb @@ -19,6 +19,6 @@ def option_exists?(option) raise(TypeError, "delimiter type does not exist: #{option}") end end - end + end end end diff --git a/lib/mathematical/corrections.rb b/lib/mathematical/corrections.rb index 6becf14..4289dd1 100644 --- a/lib/mathematical/corrections.rb +++ b/lib/mathematical/corrections.rb @@ -11,7 +11,7 @@ def apply_corrections(maths) # inside itex equations. So "<" and ">" are significant. # To obtain a less-than or greater-than sign, you should use \lt or \gt, respectively. def adjust_lt_gt(maths) - maths.gsub(//, '\gt') + maths.gsub("<", '\lt').gsub(">", '\gt') end end end diff --git a/script/install_linux_deps b/script/install_linux_deps index d4a9565..3d5102c 100755 --- a/script/install_linux_deps +++ b/script/install_linux_deps @@ -3,7 +3,7 @@ set -e export CC=gcc -sudo apt-get -qq -y install bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev +sudo apt-get -qq -y install bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev libwebp-dev # not necessary for tests, but is for any production/development environment if [[ ! -v CI ]]; then diff --git a/test/mathematical/basic_test.rb b/test/mathematical/basic_test.rb index f31a8ca..61dc2a9 100644 --- a/test/mathematical/basic_test.rb +++ b/test/mathematical/basic_test.rb @@ -3,8 +3,8 @@ require "test_helper" require "nokogiri" -module Mathematical - class BasicTest < MiniTest::Test +class Mathematical + class BasicTest < Minitest::Test def test_it_has_a_version assert(Mathematical::VERSION) end @@ -14,7 +14,7 @@ def test_multiple_calls render.render('$\pi$') output = render.render('$\pi$')[:data] - assert_equal(1, output.scan(/) end.rstrip - expected_file = before.sub(/before/, "after").sub(/text/, "html") + expected_file = before.sub("before", "after").sub("text", "html") File.open(expected_file, "w") { |file| file.write(actual) } unless ENV["DEBUG_MATHEMATICAL"].nil? diff --git a/test/mathematical/maliciousness_test.rb b/test/mathematical/maliciousness_test.rb index 4bfd00e..a0cd9c1 100644 --- a/test/mathematical/maliciousness_test.rb +++ b/test/mathematical/maliciousness_test.rb @@ -2,8 +2,8 @@ require "test_helper" -module Mathematical - class MaliciousnessTest < MiniTest::Test +class Mathematical + class MaliciousnessTest < Minitest::Test def test_it_does_not_error_on_unrecognized_commands render = Mathematical.new # In mtex2MML, we raise a ParseError, but Mathematical suppresses it and returns the string. @@ -60,9 +60,8 @@ def test_it_does_not_blow_up_on_bad_options assert_equal('$a \ne b$', output[:data]) assert_equal(output[:exception].class, Mathematical::MaxsizeError) - render = Mathematical.new({ maxsize: 2**80 }) assert_raises(TypeError) do - render.render('$a \ne b$') + render = Mathematical.new({ maxsize: 2**80 }) end end @@ -123,11 +122,11 @@ def test_it_parses_all_possible_array_elements end assert_equal(3, output.length) - assert_equal(Hash, output.first.class) - assert_equal(Hash, output.last.class) + assert_instance_of(Hash, output.first) + assert_instance_of(Hash, output.last) assert_equal("$/this___istotallyfake$", output[1][:data]) - assert_equal(Mathematical::ParseError, output[1][:exception].class) + assert_instance_of(Mathematical::ParseError, output[1][:exception]) assert_match("Failed to parse mtex", output[1][:exception].message) # array errors also output to STDERR @@ -145,7 +144,7 @@ def test_it_passes_a_legible_error_for_maxsize assert_equal(1, output.length) assert_equal('$a \ne b$', output[0][:data]) - assert_equal(Mathematical::MaxsizeError, output[0][:exception].class) + assert_instance_of(Mathematical::MaxsizeError, output[0][:exception]) assert_match("Size of latex string is greater than the maxsize", output[0][:exception].message) # array errors also output to STDERR diff --git a/test/mathematical/mathjax_test.rb b/test/mathematical/mathjax_test.rb index a4267d4..77a15f2 100644 --- a/test/mathematical/mathjax_test.rb +++ b/test/mathematical/mathjax_test.rb @@ -3,8 +3,8 @@ require "test_helper" require "nokogiri" -module Mathematical - class MathJaxTest < MiniTest::Test +class Mathematical + class MathJaxTest < Minitest::Test render_svg = Mathematical.new SKIPPED = [] diff --git a/test/mathematical/mathml_test.rb b/test/mathematical/mathml_test.rb index 96490a8..581b045 100644 --- a/test/mathematical/mathml_test.rb +++ b/test/mathematical/mathml_test.rb @@ -3,8 +3,8 @@ # rubocop:disable Lint/ImplicitStringConcatenation require "test_helper" -module Mathematical - class MathMLTest < MiniTest::Test +class Mathematical + class MathMLTest < Minitest::Test def test_it_returns_mathml string = ""' $$ diff --git a/test/mathematical/multiples_test.rb b/test/mathematical/multiples_test.rb index e875bdf..962e1eb 100644 --- a/test/mathematical/multiples_test.rb +++ b/test/mathematical/multiples_test.rb @@ -2,8 +2,8 @@ require "test_helper" -module Mathematical - class MultiplesTest < MiniTest::Test +class Mathematical + class MultiplesTest < Minitest::Test def setup @render = Mathematical.new(base64: true) end @@ -20,7 +20,7 @@ def test_it_works_for_a_single_numbered_equation output = @render.render([string]) svg = output.first[:data] - assert_equal(1, svg.scan(/svg\+xml;/).size, "should only contain one svg") + assert_equal(1, svg.scan("svg+xml;").size, "should only contain one svg") assert_match("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My", svg) end @@ -46,6 +46,7 @@ def test_it_works_for_many_equations end def test_it_properly_accounts_for_equations + skip("png tests are currently unsupported") inputs = [] (1..2).each do |i| string = """ diff --git a/test/mathematical/performance_test.rb b/test/mathematical/performance_test.rb index 35d0235..b559042 100644 --- a/test/mathematical/performance_test.rb +++ b/test/mathematical/performance_test.rb @@ -3,8 +3,8 @@ require "test_helper" require "benchmark" -module Mathematical - class BasicTest < MiniTest::Test +class Mathematical + class BasicTest < Minitest::Test def test_it_handles_big_files big_file = File.read("test/mathematical/fixtures/performance/big_file.text") speed = Benchmark.realtime do diff --git a/test/mathematical/png_test.rb b/test/mathematical/png_test.rb index 545d22d..ea8e4ec 100644 --- a/test/mathematical/png_test.rb +++ b/test/mathematical/png_test.rb @@ -4,13 +4,14 @@ require "test_helper" -module Mathematical - class PNGTest < MiniTest::Test +class Mathematical + class PNGTest < Minitest::Test def before File.delete("#{fixtures_dir}/png/pmatrix.png") if File.exist?("#{fixtures_dir}/png/pmatrix.png") end def test_it_creates_a_png + skip("png tests are currently unsupported") string = ""' $$ \begin{pmatrix}