Skip to content

Commit

Permalink
Merge pull request #289 from rails/flavorjones-platform-match-gem-dep
Browse files Browse the repository at this point in the history
dep: rubygems >= 3.2.0 for Platform#match_gem?
  • Loading branch information
flavorjones authored Oct 27, 2023
2 parents 3f34537 + 44b470d commit 6bf95b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
rubygems: latest
bundler: latest
bundler-cache: true
- name: Run tests
Expand Down
2 changes: 2 additions & 0 deletions tailwindcss-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Gem::Specification.new do |spec|
"rubygems_mfa_required" => "true"
}

spec.required_rubygems_version = ">= 3.2.0" # for Gem::Platform#match_gem?

spec.files = Dir["{app,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
spec.bindir = "exe"
spec.executables << "tailwindcss"
Expand Down
13 changes: 10 additions & 3 deletions test/lib/tailwindcss/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ def mock_exe_directory(platform)
FileUtils.mkdir(File.join(dir, platform))
path = File.join(dir, platform, "tailwindcss")
FileUtils.touch(path)
Gem::Platform.stub(:match_gem?, true) do
stub_gem_platform_match_gem(true) do
yield(dir, path)
end
end
end

def stub_gem_platform_match_gem(value)
assert_respond_to(Gem::Platform, :match_gem?)
Gem::Platform.stub(:match_gem?, value) do
yield
end
end

def mock_local_tailwindcss_install
Dir.mktmpdir do |dir|
path = File.join(dir, "tailwindcss")
Expand All @@ -35,7 +42,7 @@ def mock_local_tailwindcss_install
end

test ".executable raises UnsupportedPlatformException when we're not on a supported platform" do
Gem::Platform.stub(:match_gem?, false) do # nothing is supported
stub_gem_platform_match_gem(false) do # nothing is supported
assert_raises(Tailwindcss::Commands::UnsupportedPlatformException) do
Tailwindcss::Commands.executable
end
Expand Down Expand Up @@ -66,7 +73,7 @@ def mock_local_tailwindcss_install
end

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

0 comments on commit 6bf95b3

Please sign in to comment.