Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dep: rubygems >= 3.2.0 for Platform#match_gem? #289

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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