shakapacker 7.0.2 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dummy.yml +4 -2
  3. data/.github/workflows/generator.yml +4 -2
  4. data/.github/workflows/jest.yml +5 -3
  5. data/.github/workflows/js-lint.yml +5 -3
  6. data/.github/workflows/rubocop.yml +4 -2
  7. data/.github/workflows/ruby-backward-compatibility.yml +5 -3
  8. data/.github/workflows/ruby.yml +5 -3
  9. data/CHANGELOG.md +15 -1
  10. data/CONTRIBUTING.md +3 -4
  11. data/README.md +37 -23
  12. data/docs/deployment.md +1 -1
  13. data/docs/react.md +4 -4
  14. data/docs/troubleshooting.md +4 -8
  15. data/docs/using_esbuild_loader.md +3 -5
  16. data/docs/v6_upgrade.md +1 -1
  17. data/docs/v7_upgrade.md +2 -2
  18. data/lib/install/template.rb +2 -2
  19. data/lib/shakapacker/compiler.rb +1 -1
  20. data/lib/shakapacker/deprecation_helper.rb +1 -1
  21. data/lib/shakapacker/dev_server_runner.rb +2 -1
  22. data/lib/shakapacker/utils/misc.rb +1 -1
  23. data/lib/shakapacker/version.rb +1 -1
  24. data/lib/shakapacker/version_checker.rb +35 -2
  25. data/lib/shakapacker/webpack_runner.rb +4 -3
  26. data/lib/tasks/shakapacker/binstubs.rake +2 -2
  27. data/lib/tasks/shakapacker/check_binstubs.rake +7 -2
  28. data/lib/tasks/shakapacker/install.rake +2 -2
  29. data/package/__tests__/index.js +24 -0
  30. data/package/environments/__tests__/base-bc.js +1 -1
  31. data/package/environments/__tests__/development.js +9 -9
  32. data/package/environments/__tests__/production.js +12 -12
  33. data/package/index.d.ts +61 -0
  34. data/package/index.js +8 -2
  35. data/package.json +12 -1
  36. data/rakelib/release.rake +1 -1
  37. data/spec/backward_compatibility_specs/compiler_spec.rb +2 -2
  38. data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +5 -3
  39. data/spec/backward_compatibility_specs/configuration_spec.rb +16 -8
  40. data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +17 -16
  41. data/spec/backward_compatibility_specs/dev_server_spec.rb +1 -1
  42. data/spec/backward_compatibility_specs/digest_strategy_spec.rb +2 -0
  43. data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +2 -1
  44. data/spec/backward_compatibility_specs/helper_spec.rb +20 -20
  45. data/spec/backward_compatibility_specs/instance_spec.rb +3 -3
  46. data/spec/backward_compatibility_specs/manifest_spec.rb +12 -12
  47. data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +3 -3
  48. data/spec/backward_compatibility_specs/rake_tasks_spec.rb +9 -5
  49. data/spec/backward_compatibility_specs/webpack_runner_spec.rb +14 -18
  50. data/spec/dummy/config/webpack/commonWebpackConfig.js +1 -1
  51. data/spec/fixtures/beta_pnpm-lock.v7.yaml +116 -0
  52. data/spec/fixtures/beta_pnpm-lock.v8.yaml +2537 -0
  53. data/spec/fixtures/git_url_pnpm-lock.v7.yaml +126 -0
  54. data/spec/fixtures/git_url_pnpm-lock.v8.yaml +3728 -0
  55. data/spec/fixtures/github_url_pnpm-lock.v7.yaml +126 -0
  56. data/spec/fixtures/github_url_pnpm-lock.v8.yaml +3728 -0
  57. data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +18 -0
  58. data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +22 -0
  59. data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +117 -0
  60. data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +2558 -0
  61. data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +117 -0
  62. data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +2558 -0
  63. data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +116 -0
  64. data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +2558 -0
  65. data/spec/fixtures/without_pnpm-lock.v7.yaml +23 -0
  66. data/spec/fixtures/without_pnpm-lock.v8.yaml +27 -0
  67. data/spec/generator_specs/generator_spec.rb +11 -7
  68. data/spec/shakapacker/compiler_spec.rb +2 -2
  69. data/spec/shakapacker/compiler_strategy_spec.rb +5 -3
  70. data/spec/shakapacker/configuration_spec.rb +16 -6
  71. data/spec/shakapacker/dev_server_runner_spec.rb +22 -16
  72. data/spec/shakapacker/dev_server_spec.rb +1 -1
  73. data/spec/shakapacker/digest_strategy_spec.rb +2 -0
  74. data/spec/shakapacker/engine_rake_tasks_spec.rb +2 -1
  75. data/spec/shakapacker/helper_spec.rb +20 -20
  76. data/spec/shakapacker/instance_spec.rb +2 -2
  77. data/spec/shakapacker/manifest_spec.rb +12 -12
  78. data/spec/shakapacker/mtime_strategy_spec.rb +3 -3
  79. data/spec/shakapacker/rake_tasks_spec.rb +6 -3
  80. data/spec/shakapacker/shakapacker_spec.rb +4 -4
  81. data/spec/shakapacker/version_checker_spec.rb +470 -123
  82. data/spec/shakapacker/webpack_runner_spec.rb +14 -18
  83. metadata +20 -3
@@ -0,0 +1,23 @@
1
+ lockfileVersion: 5.4
2
+
3
+ specifiers:
4
+ left-pad: 1.0.2
5
+ right-pad: ^1.0.1
6
+
7
+ dependencies:
8
+ left-pad: 1.0.2
9
+
10
+ devDependencies:
11
+ right-pad: 1.0.1
12
+
13
+ packages:
14
+
15
+ /left-pad/1.0.2:
16
+ resolution: {integrity: sha512-i+siCE/qH/g/aFBfv9alTWzGetfoI8pw4mT4L4DA1kcCZwxnLzCpW5W96BmcNZvSsEStD0mn3NInNjp+CXb1lw==}
17
+ deprecated: use String.prototype.padStart()
18
+ dev: false
19
+
20
+ /right-pad/1.0.1:
21
+ resolution: {integrity: sha512-bYBjgxmkvTAfgIYy328fmkwhp39v8lwVgWhhrzxPV3yHtcSqyYKe9/XOhvW48UFjATg3VuJbpsp5822ACNvkmw==}
22
+ engines: {node: '>= 0.10'}
23
+ dev: true
@@ -0,0 +1,27 @@
1
+ lockfileVersion: '6.0'
2
+
3
+ settings:
4
+ autoInstallPeers: true
5
+ excludeLinksFromLockfile: false
6
+
7
+ dependencies:
8
+ left-pad:
9
+ specifier: 1.0.2
10
+ version: 1.0.2
11
+
12
+ devDependencies:
13
+ right-pad:
14
+ specifier: ^1.0.1
15
+ version: 1.0.1
16
+
17
+ packages:
18
+
19
+ /left-pad@1.0.2:
20
+ resolution: {integrity: sha512-i+siCE/qH/g/aFBfv9alTWzGetfoI8pw4mT4L4DA1kcCZwxnLzCpW5W96BmcNZvSsEStD0mn3NInNjp+CXb1lw==}
21
+ deprecated: use String.prototype.padStart()
22
+ dev: false
23
+
24
+ /right-pad@1.0.1:
25
+ resolution: {integrity: sha512-bYBjgxmkvTAfgIYy328fmkwhp39v8lwVgWhhrzxPV3yHtcSqyYKe9/XOhvW48UFjATg3VuJbpsp5822ACNvkmw==}
26
+ engines: {node: '>= 0.10'}
27
+ dev: true
@@ -33,7 +33,7 @@ describe "Generator" do
33
33
  describe "shakapacker:install" do
34
34
  context "in a normal Rails project" do
35
35
  before :all do
36
- sh_in_dir(SPEC_PATH, "cp -r #{BASE_RAILS_APP_PATH} #{TEMP_RAILS_APP_PATH}")
36
+ sh_in_dir(SPEC_PATH, "cp -r '#{BASE_RAILS_APP_PATH}' '#{TEMP_RAILS_APP_PATH}'")
37
37
 
38
38
  Bundler.with_unbundled_env do
39
39
  sh_in_dir(TEMP_RAILS_APP_PATH, "FORCE=true bundle exec rails shakapacker:install")
@@ -53,20 +53,20 @@ describe "Generator" do
53
53
  expect(actual_content).to eq expected_content
54
54
  end
55
55
 
56
- it "replaces package.json with template file" do
56
+ it "replaces package.json with the template file" do
57
57
  actual_content = read(path_in_the_app("package.json"))
58
58
 
59
59
  expect(actual_content).to match /"name": "app",/
60
60
  end
61
61
 
62
- it "creates webpack config directory and its files" do
62
+ it "creates the webpack config directory and its files" do
63
63
  expected_files = [
64
64
  "webpack.config.js"
65
65
  ]
66
66
 
67
67
  Dir.chdir(path_in_the_app("config/webpack")) do
68
- exisiting_files_in_config_webpack_dir = Dir.glob("*")
69
- expect(exisiting_files_in_config_webpack_dir).to eq expected_files
68
+ existing_files_in_config_webpack_dir = Dir.glob("*")
69
+ expect(existing_files_in_config_webpack_dir).to eq expected_files
70
70
  end
71
71
  end
72
72
 
@@ -78,6 +78,7 @@ describe "Generator" do
78
78
 
79
79
  Dir.chdir(File.join(TEMP_RAILS_APP_PATH, "bin")) do
80
80
  actual_binstubs = Dir.glob("*")
81
+
81
82
  expect(actual_binstubs).to include(*expected_binstubs)
82
83
  end
83
84
  end
@@ -94,12 +95,13 @@ describe "Generator" do
94
95
  expect(actual_content).to match '<%= javascript_pack_tag "application" %>'
95
96
  end
96
97
 
97
- it "updates `bin/setup" do
98
+ it "updates `bin/setup`" do
98
99
  setup_file_content = read(path_in_the_app("bin/setup"))
100
+
99
101
  expect(setup_file_content).to match %r(^\s*system!\(['"]bin/yarn['"]\))
100
102
  end
101
103
 
102
- it "adds relevant shakapacker version in package.json depending on gem version," do
104
+ it "uses the shakapacker version in package.json depending on gem version" do
103
105
  npm_version = Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(Shakapacker::VERSION)
104
106
 
105
107
  actual_content = read(path_in_the_app("package.json"))
@@ -143,6 +145,7 @@ describe "Generator" do
143
145
  it "passes the test for rendering react component on the page" do
144
146
  Bundler.with_unbundled_env do
145
147
  sh_in_dir(TEMP_RAILS_APP_PATH, "./bin/rails app:template LOCATION=../e2e_template/template.rb")
148
+
146
149
  expect(sh_in_dir(TEMP_RAILS_APP_PATH, "bundle exec rspec")).to be_truthy
147
150
  end
148
151
  end
@@ -151,6 +154,7 @@ describe "Generator" do
151
154
  end
152
155
 
153
156
  private
157
+
154
158
  def path_in_the_app(relative_path = nil)
155
159
  Pathname.new(File.join([TEMP_RAILS_APP_PATH, relative_path].compact))
156
160
  end
@@ -26,7 +26,7 @@ describe "Shakapacker::Compiler" do
26
26
  allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy)
27
27
 
28
28
  status = OpenStruct.new(success?: true)
29
- allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status])
29
+ allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status])
30
30
 
31
31
  expect(Shakapacker.compiler.compile).to be true
32
32
  expect(mocked_strategy).to have_received(:after_compile_hook)
@@ -40,7 +40,7 @@ describe "Shakapacker::Compiler" do
40
40
  allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy)
41
41
 
42
42
  status = OpenStruct.new(success?: false)
43
- allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status])
43
+ allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status])
44
44
 
45
45
  expect(Shakapacker.compiler.compile).to be false
46
46
  expect(mocked_strategy).to have_received(:after_compile_hook)
@@ -2,17 +2,19 @@ require_relative "spec_helper_initializer"
2
2
 
3
3
  describe "Shakapacker::CompilerStrategy" do
4
4
  describe "#from_config" do
5
- it "returns and instance of MtimeStrategy when compiler_strategy is set to mtime" do
5
+ it "returns an instance of MtimeStrategy when compiler_strategy is set to mtime" do
6
6
  allow(Shakapacker.config).to receive(:compiler_strategy).and_return("mtime")
7
+
7
8
  expect(Shakapacker::CompilerStrategy.from_config).to be_an_instance_of(Shakapacker::MtimeStrategy)
8
9
  end
9
10
 
10
- it "returns and instance of DigestStrategy when compiler_strategy is set to digest" do
11
+ it "returns an instance of DigestStrategy when compiler_strategy is set to digest" do
11
12
  allow(Shakapacker.config).to receive(:compiler_strategy).and_return("digest")
13
+
12
14
  expect(Shakapacker::CompilerStrategy.from_config).to be_an_instance_of(Shakapacker::DigestStrategy)
13
15
  end
14
16
 
15
- it "raise exception for unknown compiler_strategy in the config file" do
17
+ it "raise an exception for unknown compiler_strategy in the config file" do
16
18
  expected_error_message = "Unknown strategy 'other'. Available options are 'mtime' and 'digest'."
17
19
  allow(Shakapacker.config).to receive(:compiler_strategy).and_return("other")
18
20
 
@@ -14,36 +14,43 @@ describe "Shakapacker::Configuration" do
14
14
 
15
15
  it "#source_path returns correct path" do
16
16
  source_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/app/javascript").to_s
17
+
17
18
  expect(config.source_path.to_s).to eq source_path
18
19
  end
19
20
 
20
21
  it "#source_entry_path returns correct path" do
21
22
  source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/app/javascript", "entrypoints").to_s
23
+
22
24
  expect(config.source_entry_path.to_s).to eq source_entry_path
23
25
  end
24
26
 
25
27
  it "#public_root_path returns correct path" do
26
28
  public_root_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public").to_s
29
+
27
30
  expect(config.public_path.to_s).to eq public_root_path
28
31
  end
29
32
 
30
33
  it "#public_output_path returns correct path" do
31
34
  public_output_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs").to_s
35
+
32
36
  expect(config.public_output_path.to_s).to eq public_output_path
33
37
  end
34
38
 
35
39
  it "#public_manifest_path returns correct path" do
36
40
  public_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs", "manifest.json").to_s
41
+
37
42
  expect(config.public_manifest_path.to_s).to eq public_manifest_path
38
43
  end
39
44
 
40
45
  it "#manifest_path returns correct path" do
41
46
  manifest_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs", "manifest.json").to_s
47
+
42
48
  expect(config.manifest_path.to_s).to eq manifest_path
43
49
  end
44
50
 
45
51
  it "#cache_path returns correct path" do
46
52
  cache_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/tmp/shakapacker").to_s
53
+
47
54
  expect(config.cache_path.to_s).to eq cache_path
48
55
  end
49
56
 
@@ -56,7 +63,7 @@ describe "Shakapacker::Configuration" do
56
63
  expect(config.cache_manifest?).to be true
57
64
  end
58
65
 
59
- it "returns false in developemnt environemnt" do
66
+ it "returns false in development environment" do
60
67
  with_rails_env("development") do
61
68
  expect(Shakapacker.config.cache_manifest?).to be false
62
69
  end
@@ -74,13 +81,13 @@ describe "Shakapacker::Configuration" do
74
81
  expect(config.compile?).to be false
75
82
  end
76
83
 
77
- it "returns true in developemnt environemnt" do
84
+ it "returns true in development environment" do
78
85
  with_rails_env("development") do
79
86
  expect(Shakapacker.config.compile?).to be true
80
87
  end
81
88
  end
82
89
 
83
- it "returns true in test environemnt" do
90
+ it "returns true in test environment" do
84
91
  with_rails_env("test") do
85
92
  expect(Shakapacker.config.compile?).to be true
86
93
  end
@@ -125,7 +132,7 @@ describe "Shakapacker::Configuration" do
125
132
 
126
133
  describe "#shakapacker_precompile?" do
127
134
  before :each do
128
- ENV["SHAKAPACKER_PRECOMPILE"] = nil
135
+ ENV.delete("SHAKAPACKER_PRECOMPILE")
129
136
  end
130
137
 
131
138
  subject { config.shakapacker_precompile? }
@@ -185,11 +192,12 @@ describe "Shakapacker::Configuration" do
185
192
 
186
193
  it "#public_output_path returns correct path" do
187
194
  expected_public_output_path = File.expand_path File.join(File.dirname(__FILE__), "./public/packs").to_s
195
+
188
196
  expect(config.public_output_path.to_s).to eq expected_public_output_path
189
197
  end
190
198
  end
191
199
 
192
- context "with shakapacker config file containing manifext_path entry" do
200
+ context "with shakapacker config file containing manifest_path entry" do
193
201
  config = Shakapacker::Configuration.new(
194
202
  root_path: ROOT_PATH,
195
203
  config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_manifest_path.yml", __dir__)),
@@ -198,6 +206,7 @@ describe "Shakapacker::Configuration" do
198
206
 
199
207
  it "#manifest_path returns correct expected value" do
200
208
  expected_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/app/javascript", "manifest.json").to_s
209
+
201
210
  expect(config.manifest_path.to_s).to eq expected_manifest_path
202
211
  end
203
212
  end
@@ -205,7 +214,7 @@ describe "Shakapacker::Configuration" do
205
214
  context "with shakapacker_precompile entry set to false" do
206
215
  describe "#shakapacker_precompile?" do
207
216
  before :each do
208
- ENV["SHAKAPACKER_PRECOMPILE"] = nil
217
+ ENV.delete("SHAKAPACKER_PRECOMPILE")
209
218
  end
210
219
 
211
220
  let(:config) {
@@ -276,6 +285,7 @@ describe "Shakapacker::Configuration" do
276
285
  it "#cache_manifest? fall back to 'production' config from bundled file" do
277
286
  expect(config.cache_manifest?).to be true
278
287
  end
288
+
279
289
  it "#shakapacker_precompile? use 'staging' config from custom file" do
280
290
  expect(config.shakapacker_precompile?).to be false
281
291
  end
@@ -16,19 +16,25 @@ describe "DevServerRunner" do
16
16
 
17
17
  let(:test_app_path) { File.expand_path("./test_app", __dir__) }
18
18
 
19
- it "run cmd via node modules" do
19
+ it "supports running via node modules" do
20
20
  cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
21
+
21
22
  verify_command(cmd, use_node_modules: true)
22
23
  end
23
- it "run cmd via yarn" do
24
+
25
+ it "supports running via yarn" do
24
26
  cmd = ["yarn", "webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
27
+
25
28
  verify_command(cmd, use_node_modules: false)
26
29
  end
27
- it "run cmd argv" do
30
+
31
+ it "passes on arguments" do
28
32
  cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--quiet"]
33
+
29
34
  verify_command(cmd, argv: (["--quiet"]))
30
35
  end
31
- it "run cmd argv with https" do
36
+
37
+ it "supports the https flag" do
32
38
  cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--https"]
33
39
 
34
40
  dev_server = double()
@@ -42,31 +48,31 @@ describe "DevServerRunner" do
42
48
  verify_command(cmd, argv: (["--https"]))
43
49
  end.and_return(dev_server)
44
50
  end
51
+
45
52
  it "accepts environment variables" do
46
53
  cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
47
54
  env = Shakapacker::Compiler.env.dup
55
+
48
56
  ENV["SHAKAPACKER_CONFIG"] = env["SHAKAPACKER_CONFIG"] = "#{test_app_path}/config/shakapacker_other_location.yml"
49
57
  env["WEBPACK_SERVE"] = "true"
58
+
50
59
  verify_command(cmd, env: env)
51
60
  end
52
61
 
53
62
  private
54
63
 
55
64
  def verify_command(cmd, use_node_modules: true, argv: [], env: Shakapacker::Compiler.env)
56
- cwd = Dir.pwd
57
- Dir.chdir(test_app_path)
58
- klass = Shakapacker::DevServerRunner
59
- instance = klass.new(argv)
60
-
61
- allow(klass).to receive(:new).and_return(instance)
62
- allow(instance).to receive(:node_modules_bin_exist?).and_return(use_node_modules)
63
- allow(Kernel).to receive(:exec).with(env, *cmd)
65
+ Dir.chdir(test_app_path) do
66
+ klass = Shakapacker::DevServerRunner
67
+ instance = klass.new(argv)
64
68
 
65
- klass.run(argv)
69
+ allow(klass).to receive(:new).and_return(instance)
70
+ allow(instance).to receive(:node_modules_bin_exist?).and_return(use_node_modules)
71
+ allow(Kernel).to receive(:exec).with(env, *cmd)
66
72
 
67
- expect(Kernel).to have_received(:exec).with(env, *cmd)
73
+ klass.run(argv)
68
74
 
69
- ensure
70
- Dir.chdir(cwd)
75
+ expect(Kernel).to have_received(:exec).with(env, *cmd)
76
+ end
71
77
  end
72
78
  end
@@ -41,7 +41,7 @@ describe "DevServer" do
41
41
  end
42
42
  end
43
43
 
44
- it "users SHAKAPACKER_DEV_SERVER for DEFAULT_ENV_PREFIX" do
44
+ it "uses SHAKAPACKER_DEV_SERVER for DEFAULT_ENV_PREFIX" do
45
45
  expect(Shakapacker::DevServer::DEFAULT_ENV_PREFIX).to eq "SHAKAPACKER_DEV_SERVER"
46
46
  end
47
47
 
@@ -23,6 +23,7 @@ describe "DigestStrategy" do
23
23
 
24
24
  it "is fresh after compilation" do
25
25
  @digest_strategy.after_compile_hook
26
+
26
27
  expect(@digest_strategy.stale?).to be false
27
28
  expect(@digest_strategy.fresh?).to be true
28
29
  end
@@ -30,6 +31,7 @@ describe "DigestStrategy" do
30
31
  it "generates correct compilation_digest_path" do
31
32
  actual_path = @digest_strategy.send(:compilation_digest_path).basename.to_s
32
33
  expected_path = "last-compilation-digest-#{Shakapacker.env}"
34
+
33
35
  expect(actual_path).to eq expected_path
34
36
  end
35
37
  end
@@ -11,10 +11,11 @@ describe "EngineRakeTasks" do
11
11
 
12
12
  it "mounts app:shakapacker task successfully" do
13
13
  output = Dir.chdir(mounted_app_path) { `rake -T` }
14
+
14
15
  expect(output).to include "app:shakapacker"
15
16
  end
16
17
 
17
- it "binstubs adds only expected files to bin directory" do
18
+ it "only adds expected files to bin directory when binstubs is run" do
18
19
  Dir.chdir(mounted_app_path) { `bundle exec rake app:shakapacker:binstubs` }
19
20
  expected_binstub_paths.each { |path| expect(File.exist?(path)).to be true }
20
21
  end
@@ -22,17 +22,17 @@ module ActionView::TestCase::Behavior
22
22
  @javascript_pack_tag_loaded = nil
23
23
  end
24
24
 
25
- it "#asset_pack_path generates correct path" do
25
+ it "#asset_pack_path generates the correct path" do
26
26
  expect(asset_pack_path("bootstrap.js")).to eq "/packs/bootstrap-300631c4f0e0f9c865bc.js"
27
27
  expect(asset_pack_path("bootstrap.css")).to eq "/packs/bootstrap-c38deda30895059837cf.css"
28
28
  end
29
29
 
30
- it "#asset_pack_url generates correct url" do
30
+ it "#asset_pack_url generates the correct url" do
31
31
  expect(asset_pack_url("bootstrap.js")).to eq "https://example.com/packs/bootstrap-300631c4f0e0f9c865bc.js"
32
32
  expect(asset_pack_url("bootstrap.css")).to eq "https://example.com/packs/bootstrap-c38deda30895059837cf.css"
33
33
  end
34
34
 
35
- it "#image_pack_path generates correct path" do
35
+ it "#image_pack_path generates the correct path" do
36
36
  expect(image_pack_path("application.png")).to eq "/packs/application-k344a6d59eef8632c9d1.png"
37
37
  expect(image_pack_path("image.jpg")).to eq "/packs/static/image-c38deda30895059837cf.jpg"
38
38
  expect(image_pack_path("static/image.jpg")).to eq "/packs/static/image-c38deda30895059837cf.jpg"
@@ -40,7 +40,7 @@ module ActionView::TestCase::Behavior
40
40
  expect(image_pack_path("static/nested/image.jpg")).to eq "/packs/static/nested/image-c38deda30895059837cf.jpg"
41
41
  end
42
42
 
43
- it "#image_pack_url generates correct path" do
43
+ it "#image_pack_url generates the correct path" do
44
44
  expect(image_pack_url("application.png")).to eq "https://example.com/packs/application-k344a6d59eef8632c9d1.png"
45
45
  expect(image_pack_url("image.jpg")).to eq "https://example.com/packs/static/image-c38deda30895059837cf.jpg"
46
46
  expect(image_pack_url("static/image.jpg")).to eq "https://example.com/packs/static/image-c38deda30895059837cf.jpg"
@@ -48,7 +48,7 @@ module ActionView::TestCase::Behavior
48
48
  expect(image_pack_url("static/nested/image.jpg")).to eq "https://example.com/packs/static/nested/image-c38deda30895059837cf.jpg"
49
49
  end
50
50
 
51
- it "#image_pack_tag generates correct tags" do
51
+ it "#image_pack_tag generates the correct tags" do
52
52
  expect(image_pack_tag("application.png", size: "16x10", alt: "Edit Entry")).to eq "<img alt=\"Edit Entry\" src=\"/packs/application-k344a6d59eef8632c9d1.png\" width=\"16\" height=\"10\" />"
53
53
  expect(image_pack_tag("image.jpg", size: "16x10", alt: "Edit Entry")).to eq "<img alt=\"Edit Entry\" src=\"/packs/static/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />"
54
54
  expect(image_pack_tag("static/image.jpg", size: "16x10", alt: "Edit Entry")).to eq "<img alt=\"Edit Entry\" src=\"/packs/static/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />"
@@ -57,7 +57,7 @@ module ActionView::TestCase::Behavior
57
57
  expect(image_pack_tag("static/image.jpg", srcset: { "static/image-2x.jpg" => "2x" })).to eq "<img srcset=\"/packs/static/image-2x-7cca48e6cae66ec07b8e.jpg 2x\" src=\"/packs/static/image-c38deda30895059837cf.jpg\" />"
58
58
  end
59
59
 
60
- it "#favicon_pack_tag generates correct tags" do
60
+ it "#favicon_pack_tag generates the correct tags" do
61
61
  expect(favicon_pack_tag("application.png", rel: "apple-touch-icon", type: "image/png")).to eq "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/application-k344a6d59eef8632c9d1.png\" />"
62
62
  expect(favicon_pack_tag("mb-icon.png", rel: "apple-touch-icon", type: "image/png")).to eq "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/static/mb-icon-c38deda30895059837cf.png\" />"
63
63
  expect(favicon_pack_tag("static/mb-icon.png", rel: "apple-touch-icon", type: "image/png")).to eq "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/static/mb-icon-c38deda30895059837cf.png\" />"
@@ -65,7 +65,7 @@ module ActionView::TestCase::Behavior
65
65
  expect(favicon_pack_tag("static/nested/mb-icon.png", rel: "apple-touch-icon", type: "image/png")).to eq "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/static/nested/mb-icon-c38deda30895059837cf.png\" />"
66
66
  end
67
67
 
68
- it "#preload_pack_asset generates correct tag" do
68
+ it "#preload_pack_asset generates the correct tag" do
69
69
  if self.class.method_defined?(:preload_link_tag)
70
70
  expect(preload_pack_asset("fonts/fa-regular-400.woff2")).to eq %(<link rel="preload" href="/packs/fonts/fa-regular-400-944fb546bd7018b07190a32244f67dc9.woff2" as="font" type="font/woff2" crossorigin="anonymous">)
71
71
  else
@@ -73,7 +73,7 @@ module ActionView::TestCase::Behavior
73
73
  end
74
74
  end
75
75
 
76
- it "#javascript_pack_tag generates correct tags" do
76
+ it "#javascript_pack_tag generates the correct tags" do
77
77
  expected = <<~HTML.chomp
78
78
  <script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>
79
79
  <script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>
@@ -84,7 +84,7 @@ module ActionView::TestCase::Behavior
84
84
  expect(javascript_pack_tag("application", "bootstrap")).to eq expected
85
85
  end
86
86
 
87
- it "#javascript_pack_tag generates correct tags by passing `defer: false`" do
87
+ it "#javascript_pack_tag generates the correct tags when passing `defer: false`" do
88
88
  expected = <<~HTML.chomp
89
89
  <script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js"></script>
90
90
  <script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js"></script>
@@ -95,7 +95,7 @@ module ActionView::TestCase::Behavior
95
95
  expect(javascript_pack_tag("application", "bootstrap", defer: false)).to eq expected
96
96
  end
97
97
 
98
- it "#javascript_pack_tag generates correct appended tag" do
98
+ it "#javascript_pack_tag generates the correct appended tag" do
99
99
  append_javascript_pack_tag("bootstrap", defer: false)
100
100
 
101
101
  expected = <<~HTML.chomp
@@ -108,7 +108,7 @@ module ActionView::TestCase::Behavior
108
108
  expect(javascript_pack_tag("application")).to eq expected
109
109
  end
110
110
 
111
- it "#javascript_pack_tag generates correct prepended tag" do
111
+ it "#javascript_pack_tag generates the correct prepended tag" do
112
112
  append_javascript_pack_tag("bootstrap")
113
113
  prepend_javascript_pack_tag("main")
114
114
 
@@ -123,7 +123,7 @@ module ActionView::TestCase::Behavior
123
123
  expect(javascript_pack_tag("application")).to eq expected
124
124
  end
125
125
 
126
- it "#append_javascript_pack_tag raises error if called after calling #javascript_pack_tag" do
126
+ it "#append_javascript_pack_tag raises an error if called after calling #javascript_pack_tag" do
127
127
  expected_error_message = \
128
128
  "You can only call append_javascript_pack_tag before javascript_pack_tag helper. " +
129
129
  "Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#view-helper-append_javascript_pack_tag-prepend_javascript_pack_tag-and-append_stylesheet_pack_tag for the usage guide"
@@ -134,7 +134,7 @@ module ActionView::TestCase::Behavior
134
134
  }.to raise_error(expected_error_message)
135
135
  end
136
136
 
137
- it "#prepend_javascript_pack_tag raises error if called after calling #javascript_pack_tag" do
137
+ it "#prepend_javascript_pack_tag raises an error if called after calling #javascript_pack_tag" do
138
138
  expected_error_message = \
139
139
  "You can only call prepend_javascript_pack_tag before javascript_pack_tag helper. " +
140
140
  "Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#view-helper-append_javascript_pack_tag-prepend_javascript_pack_tag-and-append_stylesheet_pack_tag for the usage guide"
@@ -145,7 +145,7 @@ module ActionView::TestCase::Behavior
145
145
  }.to raise_error(expected_error_message)
146
146
  end
147
147
 
148
- it "#javascript_pack_tag generates correct tags by passing `defer: true`" do
148
+ it "#javascript_pack_tag generates the correct tags when passing `defer: true`" do
149
149
  expected = <<~HTML.chomp
150
150
  <script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>
151
151
  <script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>
@@ -155,7 +155,7 @@ module ActionView::TestCase::Behavior
155
155
  expect(javascript_pack_tag("application", defer: true)).to eq expected
156
156
  end
157
157
 
158
- it "#javascript_pack_tag generates correct tags by passing symbol" do
158
+ it "#javascript_pack_tag generates the correct tags when passing a symbol" do
159
159
  expected = <<~HTML.chomp
160
160
  <script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>
161
161
  <script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>
@@ -175,7 +175,7 @@ module ActionView::TestCase::Behavior
175
175
  }.to raise_error(expected_error_message)
176
176
  end
177
177
 
178
- it "#stylesheet_pack_tag generates correct link tag with string arguments" do
178
+ it "#stylesheet_pack_tag generates the correct link tag with string arguments" do
179
179
  expected = (application_stylesheet_chunks + hello_stimulus_stylesheet_chunks)
180
180
  .uniq
181
181
  .map { |chunk| stylesheet_link_tag(chunk) }
@@ -184,7 +184,7 @@ module ActionView::TestCase::Behavior
184
184
  expect(stylesheet_pack_tag("application", "hello_stimulus")).to eq expected
185
185
  end
186
186
 
187
- it "#stylesheet_pack_tag generates correct link tag with symbol arguments" do
187
+ it "#stylesheet_pack_tag generates the correct link tag with symbol arguments" do
188
188
  expected = (application_stylesheet_chunks + hello_stimulus_stylesheet_chunks)
189
189
  .uniq
190
190
  .map { |chunk| stylesheet_link_tag(chunk) }
@@ -193,7 +193,7 @@ module ActionView::TestCase::Behavior
193
193
  expect(stylesheet_pack_tag(:application, :hello_stimulus)).to eq expected
194
194
  end
195
195
 
196
- it "#stylesheet_pack_tag generates correct link tag with mixed arguments" do
196
+ it "#stylesheet_pack_tag generates the correct link tag with mixed arguments" do
197
197
  expected = (application_stylesheet_chunks)
198
198
  .map { |chunk| stylesheet_link_tag(chunk, media: "all") }
199
199
  .join("\n")
@@ -215,7 +215,7 @@ module ActionView::TestCase::Behavior
215
215
  }.to_not raise_error
216
216
  end
217
217
 
218
- it "#stylesheet_pack_tag appends" do
218
+ it "#stylesheet_pack_tag appends tags" do
219
219
  append_stylesheet_pack_tag(:hello_stimulus)
220
220
 
221
221
  expect(stylesheet_pack_tag(:application)).to eq \
@@ -230,7 +230,7 @@ module ActionView::TestCase::Behavior
230
230
  (application_stylesheet_chunks + hello_stimulus_stylesheet_chunks).uniq.map { |chunk| stylesheet_link_tag(chunk) }.join("\n")
231
231
  end
232
232
 
233
- it "#stylesheet_pack_tag supports multiple invocations with different media attr" do
233
+ it "#stylesheet_pack_tag supports multiple invocations with different media attr values" do
234
234
  app_style = stylesheet_pack_tag(:application)
235
235
  app_style_with_media = stylesheet_pack_tag(:application, media: "print")
236
236
  hello_stimulus_style_with_media = stylesheet_pack_tag(:hello_stimulus, media: "all")
@@ -13,14 +13,14 @@ describe "Shakapacker::Instance" do
13
13
  Shakapacker.instance = Shakapacker::Instance.new
14
14
  end
15
15
 
16
- it "uses default config path if no env variable defined" do
16
+ it "uses the default config path if no env variable defined" do
17
17
  actual_config_path = Rails.root.join("config/shakapacker.yml")
18
18
  expected_config_path = Shakapacker.config.config_path
19
19
 
20
20
  expect(expected_config_path).to eq(actual_config_path)
21
21
  end
22
22
 
23
- it "uses SHAKAPACKER_CONFIG env variable for config file" do
23
+ it "uses the SHAKAPACKER_CONFIG env variable for the config file path" do
24
24
  ENV["SHAKAPACKER_CONFIG"] = "/some/random/path.yml"
25
25
 
26
26
  actual_config_path = "/some/random/path.yml"