diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml index 361dabeb..dfde0647 100644 --- a/.github/workflows/stable.yml +++ b/.github/workflows/stable.yml @@ -13,6 +13,7 @@ jobs: matrix: ruby-version: + - '2.7' - '3.0' - '3.1' - '3.2' @@ -23,6 +24,8 @@ jobs: steps: - uses: actions/checkout@v4 + - run: rm Gemfile.lock + - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} diff --git a/.rubocop.yml b/.rubocop.yml index 282229de..ddbef523 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,7 +10,7 @@ AllCops: - "tmp/**/*" - "vendor/bundle/**/*" - "vendor/bundle/**/.*" - TargetRubyVersion: 3.0 + TargetRubyVersion: 2.7 NewCops: enable # we might wanna adopt rspec and rake but it's a bit annoying for now SuggestExtensions: false diff --git a/README.md b/README.md index bf9a536a..d07940f6 100644 --- a/README.md +++ b/README.md @@ -889,7 +889,7 @@ SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter ## Ruby version compatibility -SimpleCov is built in [Continuous Integration] on Ruby 3.0+ as well as JRuby 9.3+. +SimpleCov is built in [Continuous Integration] on Ruby 2.7+ as well as JRuby 9.3+. Note for JRuby => You need to pass JRUBY_OPTS="--debug" or create .jrubyrc and add debug.fullTrace=true diff --git a/features/support/env.rb b/features/support/env.rb index fb8c7592..d271a160 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -5,16 +5,21 @@ require "bundler" Bundler.setup -# require order matters, capybara needs to be there before aruba for the RSpec shadowing fix to work (see slightly below) require "capybara/cucumber" require "capybara/apparition" require "aruba/cucumber" require "aruba/config/jruby" if RUBY_ENGINE == "jruby" require "simplecov" -# Small workaround I found for the RSpec/aruba shadowing problem showcased in https://github.com/PragTob/all_conflict/ -# It _seems_ to work for now but it's definitely not ideal. Wish this was fixed in Capybara. -Aruba::Api::Core.include(Capybara::RSpecMatcherProxies) +# Monkey-patching Capybara::DSL if Capybara::DSLRSpecProxyInstaller has no `extended` hook +unless Module.new.extend(RSpec::Matchers).extend(Capybara::DSL).singleton_class.ancestors.include?(Capybara::RSpecMatcherProxies) + Capybara::DSL.extend(Module.new do + def extended(base) + base.extend(Capybara::RSpecMatcherProxies) if defined?(RSpec::Matchers) && base.is_a?(RSpec::Matchers) + super + end + end) +end # Rack app for Capybara which returns the latest coverage report from Aruba temp project dir coverage_dir = File.expand_path("../../tmp/aruba/project/coverage/", __dir__) diff --git a/lib/simplecov/lines_classifier.rb b/lib/simplecov/lines_classifier.rb index c86311c3..41026840 100644 --- a/lib/simplecov/lines_classifier.rb +++ b/lib/simplecov/lines_classifier.rb @@ -8,8 +8,8 @@ class LinesClassifier RELEVANT = 0 NOT_RELEVANT = nil - WHITESPACE_LINE = /^\s*$/ - COMMENT_LINE = /^\s*#/ + WHITESPACE_LINE = /^\s*$/.freeze + COMMENT_LINE = /^\s*#/.freeze WHITESPACE_OR_COMMENT_LINE = Regexp.union(WHITESPACE_LINE, COMMENT_LINE) def self.no_cov_line diff --git a/lib/simplecov/source_file.rb b/lib/simplecov/source_file.rb index 43fbfba6..3d9efcd6 100644 --- a/lib/simplecov/source_file.rb +++ b/lib/simplecov/source_file.rb @@ -190,7 +190,7 @@ def load_source end end - SHEBANG_REGEX = /\A#!/ + SHEBANG_REGEX = /\A#!/.freeze def shebang?(line) SHEBANG_REGEX.match?(line) end @@ -202,7 +202,7 @@ def read_lines(file, lines, current_line) lines.concat([current_line], ensure_remove_undefs(file.readlines)) end - RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/ + RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/.freeze def set_encoding_based_on_magic_comment(file, line) # Check for encoding magic comment # Encoding magic comment must be placed at first line except for shebang diff --git a/simplecov.gemspec b/simplecov.gemspec index 7a0dce10..573c1bd3 100644 --- a/simplecov.gemspec +++ b/simplecov.gemspec @@ -33,7 +33,7 @@ Gem::Specification.new do |gem| "rubygems_mfa_required" => "true" } - gem.required_ruby_version = ">= 3.0.0" + gem.required_ruby_version = ">= 2.7.0" gem.add_dependency "docile", "~> 1.1" gem.add_dependency "simplecov-html", "~> 0.11"