Skip to content

Commit 25e431d

Browse files
committed
update test matrix
1 parent dfb7e3d commit 25e431d

5 files changed

Lines changed: 22 additions & 21 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ updates:
77
open-pull-requests-limit: 10
88
cooldown:
99
default-days: 7
10+
target-branch: "master"
1011

1112
- package-ecosystem: "github-actions"
1213
directory: "/"

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ jobs:
2424
- 3.2
2525
- 3.3
2626
- 3.4
27-
- '3.5.0-preview1'
28-
- '4.0.0-preview2'
27+
- 4.0
2928
exclude:
3029
- gemfile: gemfiles/Gemfile-rails-6-1
31-
ruby: '4.0.0-preview2'
32-
- gemfile: gemfiles/Gemfile-rails-6-1
33-
ruby: '3.5.0-preview1'
30+
ruby: 4.0
3431
- gemfile: gemfiles/Gemfile-rails-7-2
3532
ruby: '3.0'
3633
- gemfile: Gemfile

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tz_platforms =
1515

1616
group :test do
1717
gem 'dotenv', '~> 3.0'
18-
gem 'rails', '~> 8.0'
18+
gem 'rails', '~> 8.1'
1919
gem 'rake', '~> 13.0'
2020
gem 'rspec', '~> 3.6'
2121
gem 'rubocop', '~> 1.0'

lib/lokalise_rails/utils.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,29 @@ module LokaliseRails
66
# Utility methods for LokaliseRails
77
module Utils
88
class << self
9-
# Retrieves the root directory of the current project.
9+
# Returns the root directory of the current project.
1010
#
11-
# If Rails is available, it returns `Rails.root`. Otherwise, it defaults
12-
# to the current working directory.
11+
# If Rails is available, this returns `Rails.root`.
12+
# Otherwise, it falls back to the current working directory.
1313
#
14-
# @return [Pathname] Pathname object pointing to the project root.
14+
# @return [Pathname] Pathname pointing to the project root.
1515
def root
16-
Pathname.new(rails_root || Dir.getwd)
16+
rails_root || Pathname.pwd
1717
end
1818

19-
# Determines the root directory of a Rails project.
19+
# Returns the root directory of a Rails application, if present.
2020
#
21-
# - Uses `Rails.root` if available.
22-
# - Falls back to `RAILS_ROOT` for older Rails versions.
23-
# - Returns `nil` if Rails is not present.
21+
# - Uses `Rails.root` when Rails is loaded.
22+
# - Falls back to `RAILS_ROOT` for legacy Rails versions.
23+
# - Returns `nil` when Rails is not available.
2424
#
25-
# @return [String, nil] Path to the root directory or `nil` if not found.
25+
# @return [Pathname, nil] Pathname pointing to the Rails root, or `nil`.
2626
def rails_root
27-
return ::Rails.root.to_s if defined?(::Rails.root) && ::Rails.root
28-
return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
29-
30-
nil
27+
if defined?(::Rails) && ::Rails.respond_to?(:root) && ::Rails.root
28+
Pathname(::Rails.root)
29+
elsif defined?(::RAILS_ROOT)
30+
Pathname(::RAILS_ROOT)
31+
end
3132
end
3233
end
3334
end

spec/lib/lokalise_rails/utils_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# frozen_string_literal: true
22

3+
require 'pathname'
4+
35
describe LokaliseRails::Utils do
46
describe '.rails_root' do
57
it 'returns RAILS_ROOT if defined' do
68
allow(Rails).to receive(:root).and_return(nil)
79
stub_const('RAILS_ROOT', '/stub')
8-
expect(described_class.rails_root).to eq('/stub')
10+
expect(described_class.rails_root).to eq(Pathname.new('/stub'))
911
end
1012

1113
it 'fallbacks if neither roots are present' do

0 commit comments

Comments
 (0)