Skip to content

Commit

Permalink
test: deduplicate temp directory helper
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Mar 25, 2024
1 parent 293e3f3 commit e5a2747
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
6 changes: 0 additions & 6 deletions spec/shakapacker/dev_server_runner_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
require_relative "spec_helper_initializer"
require "shakapacker/dev_server_runner"

def within_temp_directory(tmpdir = nil, &block)
Dir.mktmpdir("shakapacker-", tmpdir) do |dir|
Dir.chdir(dir, &block)
end
end

describe "DevServerRunner" do
around do |example|
within_temp_directory do
Expand Down
6 changes: 0 additions & 6 deletions spec/shakapacker/manager_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ def exitstatus
end
end

def within_temp_directory(tmpdir = nil, &block)
Dir.mktmpdir("shakapacker-", tmpdir) do |dir|
Dir.chdir(dir, &block)
end
end

describe "ManagerChecker" do
around do |example|
within_temp_directory { example.run }
Expand Down
6 changes: 0 additions & 6 deletions spec/shakapacker/webpack_runner_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
require_relative "spec_helper_initializer"
require "shakapacker/webpack_runner"

def within_temp_directory(tmpdir = nil, &block)
Dir.mktmpdir("shakapacker-", tmpdir) do |dir|
Dir.chdir(dir, &block)
end
end

describe "WebpackRunner" do
around do |example|
within_temp_directory do
Expand Down
6 changes: 6 additions & 0 deletions spec/support/package_json_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ def with_package_json_fallback_manager(fallback_manager)
ENV["PACKAGE_JSON_FALLBACK_MANAGER"] = old_package_json_fallback_manager_value
end
end

def within_temp_directory(tmpdir = nil, &block)
Dir.mktmpdir("shakapacker-", tmpdir) do |dir|
Dir.chdir(dir, &block)
end
end

0 comments on commit e5a2747

Please sign in to comment.