Skip to content

Commit

Permalink
chore: rename test_app_path -> path_to_test_app (avoids minitest …
Browse files Browse the repository at this point in the history
…warning) (ElMassimo#471)
  • Loading branch information
mjankowski authored Jul 16, 2024
1 parent a4f8c56 commit 2dec06c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def assert_pathname(expected, actual)
assert_equal Pathname.new(expand_path("test_app/#{ expected }")), actual
end

def resolve_config(mode: 'production', root: test_app_path, **attrs)
def resolve_config(mode: 'production', root: path_to_test_app, **attrs)
ViteRuby::Config.resolve_config(mode: mode, root: root, **attrs)
end

Expand Down
2 changes: 1 addition & 1 deletion test/engine_rake_tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def remove_vite_files
[app_frontend_dir, app_public_dir, app_ssr_dir, tmp_dir].each do |dir|
dir.rmtree if dir.exist?
end
root_dir.join('app/views/layouts/application.html.erb').write(Pathname.new(test_app_path).join('app/views/layouts/application.html.erb').read)
root_dir.join('app/views/layouts/application.html.erb').write(Pathname.new(path_to_test_app).join('app/views/layouts/application.html.erb').read)
gitignore_path.write('')
@command_results = []
end
Expand Down
14 changes: 7 additions & 7 deletions test/rake_tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class RakeTasksTest < ViteRuby::Test
def test_rake_tasks
assert ViteRuby.install_tasks
output = Dir.chdir(test_app_path) { `rake -T` }
output = Dir.chdir(path_to_test_app) { `rake -T` }
assert_includes output, 'vite:build'
assert_includes output, 'vite:build_ssr'
assert_includes output, 'vite:clean'
Expand All @@ -15,15 +15,15 @@ def test_rake_tasks
end

def test_rake_task_vite_check_binstubs
output = Dir.chdir(test_app_path) { `rake vite:verify_install 2>&1` }
output = Dir.chdir(path_to_test_app) { `rake vite:verify_install 2>&1` }
refute_includes output, 'vite binstub not found.'
end

def test_rake_vite_install_dependencies_in_non_production_environments
assert_includes test_app_dev_dependencies, 'right-pad'

ViteRuby.commands.send(:with_node_env, 'test') do
Dir.chdir(test_app_path) do
Dir.chdir(path_to_test_app) do
`bundle exec rake vite:install_dependencies`
end
end
Expand All @@ -34,7 +34,7 @@ def test_rake_vite_install_dependencies_in_non_production_environments

def test_rake_vite_install_dependencies_in_production_environment
ViteRuby.commands.send(:with_node_env, 'production') do
Dir.chdir(test_app_path) do
Dir.chdir(path_to_test_app) do
`bundle exec rake vite:install_dependencies`
end
end
Expand All @@ -45,17 +45,17 @@ def test_rake_vite_install_dependencies_in_production_environment

private

def test_app_path
def path_to_test_app
File.expand_path('test_app', __dir__)
end

def test_app_dev_dependencies
package_json = File.expand_path('package.json', test_app_path)
package_json = File.expand_path('package.json', path_to_test_app)
JSON.parse(File.read(package_json))['devDependencies']
end

def installed_node_module_names
node_modules_path = File.expand_path('node_modules', test_app_path)
node_modules_path = File.expand_path('node_modules', path_to_test_app)
Dir.chdir(node_modules_path) { Dir.glob('*') }
end
end
4 changes: 2 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def with_rails_env(env)
refresh_config
end

def test_app_path
def path_to_test_app
File.expand_path('test_app', __dir__)
end

Expand All @@ -70,7 +70,7 @@ def stub_builder(build_errors: '', build_successful: build_errors.empty?, stale:
end

def assert_run_command(*argv, flags: [])
Dir.chdir(test_app_path) {
Dir.chdir(path_to_test_app) {
begin
mock = Minitest::Mock.new
mock.expect(:call, nil, [ViteRuby.config.to_env, %r{node_modules/.bin/vite}, *argv, *flags])
Expand Down

0 comments on commit 2dec06c

Please sign in to comment.