Skip to content

Commit 5cf051f

Browse files
authored
Merge pull request #1107 from amatsuda/ruby27
Bring Ruby 2.7 support back
2 parents c7102e4 + 0022b47 commit 5cf051f

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

.github/workflows/stable.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313

1414
matrix:
1515
ruby-version:
16+
- '2.7'
1617
- '3.0'
1718
- '3.1'
1819
- '3.2'
@@ -23,6 +24,8 @@ jobs:
2324
steps:
2425
- uses: actions/checkout@v4
2526

27+
- run: rm Gemfile.lock
28+
2629
- uses: ruby/setup-ruby@v1
2730
with:
2831
ruby-version: ${{ matrix.ruby-version }}

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AllCops:
1010
- "tmp/**/*"
1111
- "vendor/bundle/**/*"
1212
- "vendor/bundle/**/.*"
13-
TargetRubyVersion: 3.0
13+
TargetRubyVersion: 2.7
1414
NewCops: enable
1515
# we might wanna adopt rspec and rake but it's a bit annoying for now
1616
SuggestExtensions: false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
889889

890890
## Ruby version compatibility
891891

892-
SimpleCov is built in [Continuous Integration] on Ruby 3.0+ as well as JRuby 9.3+.
892+
SimpleCov is built in [Continuous Integration] on Ruby 2.7+ as well as JRuby 9.3+.
893893

894894
Note for JRuby => You need to pass JRUBY_OPTS="--debug" or create .jrubyrc and add debug.fullTrace=true
895895

features/support/env.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55

66
require "bundler"
77
Bundler.setup
8-
# require order matters, capybara needs to be there before aruba for the RSpec shadowing fix to work (see slightly below)
98
require "capybara/cucumber"
109
require "capybara/apparition"
1110
require "aruba/cucumber"
1211
require "aruba/config/jruby" if RUBY_ENGINE == "jruby"
1312
require "simplecov"
1413

15-
# Small workaround I found for the RSpec/aruba shadowing problem showcased in https://github.com/PragTob/all_conflict/
16-
# It _seems_ to work for now but it's definitely not ideal. Wish this was fixed in Capybara.
17-
Aruba::Api::Core.include(Capybara::RSpecMatcherProxies)
14+
# Monkey-patching Capybara::DSL if Capybara::DSLRSpecProxyInstaller has no `extended` hook
15+
unless Module.new.extend(RSpec::Matchers).extend(Capybara::DSL).singleton_class.ancestors.include?(Capybara::RSpecMatcherProxies)
16+
Capybara::DSL.extend(Module.new do
17+
def extended(base)
18+
base.extend(Capybara::RSpecMatcherProxies) if defined?(RSpec::Matchers) && base.is_a?(RSpec::Matchers)
19+
super
20+
end
21+
end)
22+
end
1823

1924
# Rack app for Capybara which returns the latest coverage report from Aruba temp project dir
2025
coverage_dir = File.expand_path("../../tmp/aruba/project/coverage/", __dir__)

lib/simplecov/lines_classifier.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class LinesClassifier
88
RELEVANT = 0
99
NOT_RELEVANT = nil
1010

11-
WHITESPACE_LINE = /^\s*$/
12-
COMMENT_LINE = /^\s*#/
11+
WHITESPACE_LINE = /^\s*$/.freeze
12+
COMMENT_LINE = /^\s*#/.freeze
1313
WHITESPACE_OR_COMMENT_LINE = Regexp.union(WHITESPACE_LINE, COMMENT_LINE)
1414

1515
def self.no_cov_line

lib/simplecov/source_file.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def load_source
190190
end
191191
end
192192

193-
SHEBANG_REGEX = /\A#!/
193+
SHEBANG_REGEX = /\A#!/.freeze
194194
def shebang?(line)
195195
SHEBANG_REGEX.match?(line)
196196
end
@@ -202,7 +202,7 @@ def read_lines(file, lines, current_line)
202202
lines.concat([current_line], ensure_remove_undefs(file.readlines))
203203
end
204204

205-
RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/
205+
RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/.freeze
206206
def set_encoding_based_on_magic_comment(file, line)
207207
# Check for encoding magic comment
208208
# Encoding magic comment must be placed at first line except for shebang

simplecov.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Gem::Specification.new do |gem|
3333
"rubygems_mfa_required" => "true"
3434
}
3535

36-
gem.required_ruby_version = ">= 3.0.0"
36+
gem.required_ruby_version = ">= 2.7.0"
3737

3838
gem.add_dependency "docile", "~> 1.1"
3939
gem.add_dependency "simplecov-html", "~> 0.11"

0 commit comments

Comments
 (0)