Skip to content

Commit

Permalink
chore: autocorrect string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
ElMassimo committed Nov 5, 2024
1 parent 3d7fed1 commit 9f708fd
Show file tree
Hide file tree
Showing 81 changed files with 640 additions and 640 deletions.
20 changes: 10 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

gem 'rails'
gem "rails"

gemspec path: './vite_ruby'
gemspec path: './vite_rails'
gemspec path: './vite_plugin_legacy'
gemspec path: "./vite_ruby"
gemspec path: "./vite_rails"
gemspec path: "./vite_plugin_legacy"

group :development, :test do
gem 'benchmark-ips'
gem 'rubocop'
gem 'rubocop-minitest'
gem 'rubocop-performance'
gem 'standard', require: false
gem "benchmark-ips"
gem "rubocop"
gem "rubocop-minitest"
gem "rubocop-performance"
gem "standard", require: false
end
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require 'rake/testtask'
require "rake/testtask"

Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.verbose = true
end

Expand Down
16 changes: 8 additions & 8 deletions bin/m
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require 'rubygems'
require 'bundler/setup'
require "rubygems"
require "bundler/setup"

ARGV.each_with_index do |arg, index|
ARGV[index] = arg.sub(File.expand_path(Dir.pwd), '')
ARGV[index] = arg.sub(File.expand_path(Dir.pwd), "")
end

load Gem.bin_path('m', 'm')
load Gem.bin_path("m", "m")
14 changes: 7 additions & 7 deletions bin/rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require 'rubygems'
require 'bundler/setup'
require "rubygems"
require "bundler/setup"

load Gem.bin_path('rake', 'rake')
load Gem.bin_path("rake", "rake")
14 changes: 7 additions & 7 deletions bin/rubocop
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path('bundle', __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require 'rubygems'
require 'bundler/setup'
require "rubygems"
require "bundler/setup"

load Gem.bin_path('rubocop', 'rubocop')
load Gem.bin_path("rubocop", "rubocop")
48 changes: 24 additions & 24 deletions test/builder_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require 'test_helper'
require 'open3'
require "test_helper"
require "open3"

class BuilderTest < ViteRuby::Test
delegate :builder, :manifest, to: 'ViteRuby.instance'
delegate :builder, :manifest, to: "ViteRuby.instance"

def last_build
builder.last_build_metadata
Expand All @@ -26,11 +26,11 @@ def vite_env(*vars)
end

def test_custom_environment_variables
assert_nil vite_env['FOO']
ViteRuby.env['FOO'] = 'BAR'
assert_nil vite_env["FOO"]
ViteRuby.env["FOO"] = "BAR"

assert_equal 'BAR', vite_env['FOO']
assert_equal 'OTHER', vite_env('FOO' => 'OTHER')['FOO']
assert_equal "BAR", vite_env["FOO"]
assert_equal "OTHER", vite_env("FOO" => "OTHER")["FOO"]
end

def test_freshness
Expand All @@ -50,13 +50,13 @@ def test_freshness_on_build_success

refresh_config(auto_build: true)

refute_nil manifest.send(:lookup, 'app.css')
refute_nil manifest.send(:lookup, "app.css")
}
end

def test_freshness_on_build_fail
assert_predicate last_build, :stale?
error_message = 'SyntaxError: Hero.jsx: Unexpected token (6:6)'
error_message = "SyntaxError: Hero.jsx: Unexpected token (6:6)"
stub_runner(errors: error_message) {
refute builder.build
refute last_build.success
Expand All @@ -67,7 +67,7 @@ def test_freshness_on_build_fail

refresh_config(auto_build: true)

assert_nil manifest.send(:lookup, 'app.css')
assert_nil manifest.send(:lookup, "app.css")
}
end

Expand All @@ -84,46 +84,46 @@ def test_watched_files_digest
end

def test_external_env_variables
assert_equal 'production', vite_env['VITE_RUBY_MODE']
assert_equal Rails.root.to_s, vite_env['VITE_RUBY_ROOT']
assert_equal "production", vite_env["VITE_RUBY_MODE"]
assert_equal Rails.root.to_s, vite_env["VITE_RUBY_ROOT"]

ENV['VITE_RUBY_MODE'] = 'foo.bar'
ENV['VITE_RUBY_ROOT'] = '/baz'
ENV["VITE_RUBY_MODE"] = "foo.bar"
ENV["VITE_RUBY_ROOT"] = "/baz"
refresh_config

assert_equal 'foo.bar', vite_env['VITE_RUBY_MODE']
assert_equal '/baz', vite_env['VITE_RUBY_ROOT']
assert_equal "foo.bar", vite_env["VITE_RUBY_MODE"]
assert_equal "/baz", vite_env["VITE_RUBY_ROOT"]
ensure
ENV.delete('VITE_RUBY_MODE')
ENV.delete('VITE_RUBY_ROOT')
ENV.delete("VITE_RUBY_MODE")
ENV.delete("VITE_RUBY_ROOT")
refresh_config
end

def test_missing_executable
refresh_config(vite_bin_path: 'none/vite')
refresh_config(vite_bin_path: "none/vite")

# It fails because we stub the File.exist? check, so the binary is missing.
error = assert_raises(ViteRuby::MissingExecutableError) {
File.stub(:exist?, true) { builder.build }
}

assert_match 'The vite binary is not available.', error.message
assert_match "The vite binary is not available.", error.message

# The provided binary does not exist, so it uses the default strategy.
stub_runner(success: true) { assert builder.build }
end

def test_build_cache
build = ViteRuby::Build.from_previous(Pathname.new(__FILE__), 'digest')
build = ViteRuby::Build.from_previous(Pathname.new(__FILE__), "digest")

assert_equal('never', build.timestamp)
assert_equal("never", build.timestamp)
assert_predicate(build, :retry_failed?)
end

private

def stub_runner(errors: '', success: errors.empty?, &block)
args = ['stdout', errors, MockProcessStatus.new(success: success)]
def stub_runner(errors: "", success: errors.empty?, &block)
args = ["stdout", errors, MockProcessStatus.new(success: success)]
ViteRuby::IO.stub(:capture, args, &block)
end
end
12 changes: 6 additions & 6 deletions test/commands_test.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require 'test_helper'
require "test_helper"

class CommandsTest < ViteRuby::Test
def test_bootstrap
assert ViteRuby.bootstrap
end

delegate :build, :build_from_task, :clobber, to: 'ViteRuby.commands'
delegate :build, :build_from_task, :clobber, to: "ViteRuby.commands"

def test_build_returns_success_status_when_stale
stub_builder(stale: true, build_successful: true) {
Expand Down Expand Up @@ -36,9 +36,9 @@ def test_build_returns_failure_status_when_stale
end

def test_clobber
with_rails_env('test') { |config|
with_rails_env("test") { |config|
ensure_output_dirs(config)
config.build_output_dir.join('.vite/manifest.json').write('{}')
config.build_output_dir.join(".vite/manifest.json").write("{}")

assert_path_exists config.build_output_dir
clobber
Expand All @@ -52,7 +52,7 @@ def test_clobber
def ensure_output_dirs(config)
config.build_output_dir.rmtree rescue nil
config.build_output_dir.mkdir unless config.build_output_dir.exist?
config.build_output_dir.join('.vite').mkdir unless config.build_output_dir.join('.vite').exist?
config.build_output_dir.join('assets').mkdir unless config.build_output_dir.join('assets').exist?
config.build_output_dir.join(".vite").mkdir unless config.build_output_dir.join(".vite").exist?
config.build_output_dir.join("assets").mkdir unless config.build_output_dir.join("assets").exist?
end
end
26 changes: 13 additions & 13 deletions test/compatibility_check_test.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# frozen_string_literal: true

require 'test_helper'
require "test_helper"

class CompatibilityCheckTest < ViteRuby::Test
delegate :verify_plugin_version, :raise_unless_satisfied, :compatible_plugin?, to: 'ViteRuby::CompatibilityCheck'
delegate :verify_plugin_version, :raise_unless_satisfied, :compatible_plugin?, to: "ViteRuby::CompatibilityCheck"

def test_verify_plugin_version
refresh_config(skip_compatibility_check: true)
assert_raises(ArgumentError) { refresh_config(skip_compatibility_check: false) }
end

def test_compatible_plugin
refute compatible_plugin?('^3.1.0', '^3.0.1')
refute compatible_plugin?('^4.1.0', '^3.0')
refute compatible_plugin?('4.1.0', '^3.0')
refute compatible_plugin?("^3.1.0", "^3.0.1")
refute compatible_plugin?("^4.1.0", "^3.0")
refute compatible_plugin?("4.1.0", "^3.0")

assert compatible_plugin?('3.0.5', '^3.0.1')
assert compatible_plugin?('^3.0.9', '^3.0.1')
assert compatible_plugin?('3.1.0', '^3.0')
assert compatible_plugin?('^3.1.0', '^3.0')
assert compatible_plugin?(nil, '^3.0')
assert compatible_plugin?("3.0.5", "^3.0.1")
assert compatible_plugin?("^3.0.9", "^3.0.1")
assert compatible_plugin?("3.1.0", "^3.0")
assert compatible_plugin?("^3.1.0", "^3.0")
assert compatible_plugin?(nil, "^3.0")
assert compatible_plugin?(nil, nil)
end

def test_raise_unless_satisfied
assert_raises(ArgumentError) { raise_unless_satisfied('^4.1.0', '^3.0') }
raise_unless_satisfied('3.1.0', '^3.0')
raise_unless_satisfied(nil, '^3.0')
assert_raises(ArgumentError) { raise_unless_satisfied("^4.1.0", "^3.0") }
raise_unless_satisfied("3.1.0", "^3.0")
raise_unless_satisfied(nil, "^3.0")
end
end
Loading

0 comments on commit 9f708fd

Please sign in to comment.