Skip to content

Commit 6bf95b3

Browse files
authored
Merge pull request rails#289 from rails/flavorjones-platform-match-gem-dep
dep: rubygems >= 3.2.0 for Platform#match_gem?
2 parents 3f34537 + 44b470d commit 6bf95b3

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- uses: ruby/setup-ruby@v1
2727
with:
2828
ruby-version: ${{matrix.ruby}}
29+
rubygems: latest
2930
bundler: latest
3031
bundler-cache: true
3132
- name: Run tests

tailwindcss-rails.gemspec

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Gem::Specification.new do |spec|
1414
"rubygems_mfa_required" => "true"
1515
}
1616

17+
spec.required_rubygems_version = ">= 3.2.0" # for Gem::Platform#match_gem?
18+
1719
spec.files = Dir["{app,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
1820
spec.bindir = "exe"
1921
spec.executables << "tailwindcss"

test/lib/tailwindcss/commands_test.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ def mock_exe_directory(platform)
77
FileUtils.mkdir(File.join(dir, platform))
88
path = File.join(dir, platform, "tailwindcss")
99
FileUtils.touch(path)
10-
Gem::Platform.stub(:match_gem?, true) do
10+
stub_gem_platform_match_gem(true) do
1111
yield(dir, path)
1212
end
1313
end
1414
end
1515

16+
def stub_gem_platform_match_gem(value)
17+
assert_respond_to(Gem::Platform, :match_gem?)
18+
Gem::Platform.stub(:match_gem?, value) do
19+
yield
20+
end
21+
end
22+
1623
def mock_local_tailwindcss_install
1724
Dir.mktmpdir do |dir|
1825
path = File.join(dir, "tailwindcss")
@@ -35,7 +42,7 @@ def mock_local_tailwindcss_install
3542
end
3643

3744
test ".executable raises UnsupportedPlatformException when we're not on a supported platform" do
38-
Gem::Platform.stub(:match_gem?, false) do # nothing is supported
45+
stub_gem_platform_match_gem(false) do # nothing is supported
3946
assert_raises(Tailwindcss::Commands::UnsupportedPlatformException) do
4047
Tailwindcss::Commands.executable
4148
end
@@ -66,7 +73,7 @@ def mock_local_tailwindcss_install
6673
end
6774

6875
test ".executable returns the executable in TAILWINDCSS_INSTALL_DIR when we're not on a supported platform" do
69-
Gem::Platform.stub(:match_gem?, false) do # nothing is supported
76+
stub_gem_platform_match_gem(false) do # nothing is supported
7077
mock_local_tailwindcss_install do |local_install_dir, expected|
7178
result = nil
7279
begin

0 commit comments

Comments
 (0)