shakapacker 7.0.3 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dummy.yml +3 -1
  3. data/.github/workflows/generator.yml +3 -1
  4. data/.github/workflows/jest.yml +4 -2
  5. data/.github/workflows/js-lint.yml +4 -2
  6. data/.github/workflows/rubocop.yml +3 -1
  7. data/.github/workflows/ruby-backward-compatibility.yml +3 -1
  8. data/.github/workflows/ruby.yml +4 -2
  9. data/CHANGELOG.md +7 -0
  10. data/README.md +29 -20
  11. data/docs/troubleshooting.md +4 -8
  12. data/docs/using_esbuild_loader.md +2 -4
  13. data/lib/install/template.rb +2 -2
  14. data/lib/shakapacker/deprecation_helper.rb +1 -1
  15. data/lib/shakapacker/dev_server_runner.rb +2 -1
  16. data/lib/shakapacker/version.rb +1 -1
  17. data/lib/shakapacker/version_checker.rb +35 -2
  18. data/lib/shakapacker/webpack_runner.rb +4 -3
  19. data/package/__tests__/index.js +24 -0
  20. data/package/index.d.ts +1 -1
  21. data/package/index.js +8 -2
  22. data/package.json +1 -1
  23. data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +5 -3
  24. data/spec/backward_compatibility_specs/configuration_spec.rb +12 -4
  25. data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +17 -16
  26. data/spec/backward_compatibility_specs/dev_server_spec.rb +1 -1
  27. data/spec/backward_compatibility_specs/digest_strategy_spec.rb +2 -0
  28. data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +2 -1
  29. data/spec/backward_compatibility_specs/helper_spec.rb +20 -20
  30. data/spec/backward_compatibility_specs/instance_spec.rb +3 -3
  31. data/spec/backward_compatibility_specs/manifest_spec.rb +12 -12
  32. data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +3 -3
  33. data/spec/backward_compatibility_specs/rake_tasks_spec.rb +9 -5
  34. data/spec/backward_compatibility_specs/webpack_runner_spec.rb +14 -18
  35. data/spec/dummy/config/webpack/commonWebpackConfig.js +1 -1
  36. data/spec/fixtures/beta_pnpm-lock.v7.yaml +116 -0
  37. data/spec/fixtures/beta_pnpm-lock.v8.yaml +2537 -0
  38. data/spec/fixtures/git_url_pnpm-lock.v7.yaml +126 -0
  39. data/spec/fixtures/git_url_pnpm-lock.v8.yaml +3728 -0
  40. data/spec/fixtures/github_url_pnpm-lock.v7.yaml +126 -0
  41. data/spec/fixtures/github_url_pnpm-lock.v8.yaml +3728 -0
  42. data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +18 -0
  43. data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +22 -0
  44. data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +117 -0
  45. data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +2558 -0
  46. data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +117 -0
  47. data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +2558 -0
  48. data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +116 -0
  49. data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +2558 -0
  50. data/spec/fixtures/without_pnpm-lock.v7.yaml +23 -0
  51. data/spec/fixtures/without_pnpm-lock.v8.yaml +27 -0
  52. data/spec/generator_specs/generator_spec.rb +7 -3
  53. data/spec/shakapacker/compiler_strategy_spec.rb +5 -3
  54. data/spec/shakapacker/configuration_spec.rb +12 -2
  55. data/spec/shakapacker/dev_server_runner_spec.rb +22 -16
  56. data/spec/shakapacker/dev_server_spec.rb +1 -1
  57. data/spec/shakapacker/digest_strategy_spec.rb +2 -0
  58. data/spec/shakapacker/engine_rake_tasks_spec.rb +2 -1
  59. data/spec/shakapacker/helper_spec.rb +20 -20
  60. data/spec/shakapacker/instance_spec.rb +2 -2
  61. data/spec/shakapacker/manifest_spec.rb +12 -12
  62. data/spec/shakapacker/mtime_strategy_spec.rb +3 -3
  63. data/spec/shakapacker/rake_tasks_spec.rb +5 -2
  64. data/spec/shakapacker/shakapacker_spec.rb +4 -4
  65. data/spec/shakapacker/version_checker_spec.rb +468 -121
  66. data/spec/shakapacker/webpack_runner_spec.rb +14 -18
  67. metadata +19 -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
@@ -53,13 +53,13 @@ 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
  ]
@@ -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
@@ -96,10 +97,11 @@ describe "Generator" do
96
97
 
97
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
@@ -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
 
@@ -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,6 +192,7 @@ 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
@@ -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"
@@ -3,7 +3,7 @@ require_relative "spec_helper_initializer"
3
3
  describe "Shakapacker::Manifest" do
4
4
  let(:manifest_path) { File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs", "manifest.json").to_s }
5
5
 
6
- it "#lookup! throws exception for a non-existing asset file" do
6
+ it "#lookup! raises an exception for a non-existing asset file" do
7
7
  asset_file = "calendar.js"
8
8
  expected_error_message = "Shakapacker can't find #{asset_file} in #{manifest_path}"
9
9
 
@@ -14,7 +14,7 @@ describe "Shakapacker::Manifest" do
14
14
  }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
15
15
  end
16
16
 
17
- it "#lookup! throws exception for a non-existing asset file with type and without extension" do
17
+ it "#lookup! raises an exception for a non-existing asset file with type and without an extension" do
18
18
  asset_file = "calendar"
19
19
  expected_error_message = "Shakapacker can't find #{asset_file}.js in #{manifest_path}"
20
20
 
@@ -25,57 +25,57 @@ describe "Shakapacker::Manifest" do
25
25
  }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
26
26
  end
27
27
 
28
- it "#lookup! returns path to bundled bootstrap.js" do
28
+ it "#lookup! returns the path to the bundled bootstrap.js" do
29
29
  actual = Shakapacker.manifest.lookup!("bootstrap.js")
30
30
  expected = "/packs/bootstrap-300631c4f0e0f9c865bc.js"
31
31
 
32
32
  expect(actual).to eq expected
33
33
  end
34
34
 
35
- it "#lookup_pack_with_chunks! returns array of path to bundled bootstrap with type of javascript" do
35
+ it "#lookup_pack_with_chunks! returns an array of paths to the bundled bootstrap of type javascript" do
36
36
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("bootstrap", type: :javascript)
37
37
  expected = ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
38
38
 
39
39
  expect(actual).to eq expected
40
40
  end
41
41
 
42
- it "#lookup_with_chunks! returns array of path to bundled bootstrap.js with type of javascript" do
42
+ it "#lookup_with_chunks! returns an array of paths to the bundled bootstrap.js of type javascript" do
43
43
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("bootstrap.js", type: :javascript)
44
44
  expected = ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
45
45
 
46
46
  expect(actual).to eq expected
47
47
  end
48
48
 
49
- it "#lookup_with_chunks! returns array of path to bundled 'print/application' without extension and in a sub-directory" do
49
+ it "#lookup_with_chunks! returns an array of paths to the bundled 'print/application' without an extension and in a sub-directory" do
50
50
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("print/application", type: :css)
51
51
  expected = ["/packs/print/application-983b6c164a47f7ed49cd.css"]
52
52
 
53
53
  expect(actual).to eq expected
54
54
  end
55
55
 
56
- it "#lookup_with_chunks! returns array of path to bundled 'print/application.css' in a sub-directory" do
56
+ it "#lookup_with_chunks! returns an array of paths to the bundled 'print/application.css' in a sub-directory" do
57
57
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("print/application.css", type: :css)
58
58
  expected = ["/packs/print/application-983b6c164a47f7ed49cd.css"]
59
59
 
60
60
  expect(actual).to eq expected
61
61
  end
62
62
 
63
- it "#lookup returns nil for non-existing asset file" do
63
+ it "#lookup returns nil for non-existing asset files" do
64
64
  expect(Shakapacker.manifest.lookup("foo.js")).to be nil
65
65
  end
66
66
 
67
- it "#lookup_pack_with_chunks returns nil for non-existing asset file" do
67
+ it "#lookup_pack_with_chunks returns nil for non-existing asset files" do
68
68
  expect(Shakapacker.manifest.lookup_pack_with_chunks("foo.js")).to be nil
69
69
  end
70
70
 
71
- it "#lookup returns path for bootstrap.js" do
71
+ it "#lookup returns the path for bootstrap.js" do
72
72
  actual = Shakapacker.manifest.lookup("bootstrap.js")
73
73
  expected = "/packs/bootstrap-300631c4f0e0f9c865bc.js"
74
74
 
75
75
  expect(actual).to eq expected
76
76
  end
77
77
 
78
- it "#lookup_pack_with_chunks! throws exception for a non-existing asset file" do
78
+ it "#lookup_pack_with_chunks! raises an exception for non-existing asset files" do
79
79
  asset_file = "calendar"
80
80
 
81
81
  expected_error_message = "Shakapacker can't find #{asset_file}.js in #{manifest_path}"
@@ -87,7 +87,7 @@ describe "Shakapacker::Manifest" do
87
87
  }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
88
88
  end
89
89
 
90
- it "#lookup_pack_with_chunks! returns array of paths to bundled js files with 'application' in their name" do
90
+ it "#lookup_pack_with_chunks! returns an array of paths to bundled js files with 'application' in their name" do
91
91
  actual_application_entrypoints = Shakapacker.manifest.lookup_pack_with_chunks!("application", type: :javascript)
92
92
  expected_application_entrypoints = [
93
93
  "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
@@ -5,7 +5,7 @@ describe "Shakapacker::MtimeStrategy" do
5
5
  let(:manifest_timestamp) { Time.parse("2021-01-01 12:34:56 UTC") }
6
6
 
7
7
  describe "#fresh?" do
8
- it "returns false when manifest is missing" do
8
+ it "returns false when the manifest is missing" do
9
9
  latest_timestamp = manifest_timestamp + 3600
10
10
 
11
11
  with_stubs(latest_timestamp: latest_timestamp.to_i, manifest_exists: false) do
@@ -13,7 +13,7 @@ describe "Shakapacker::MtimeStrategy" do
13
13
  end
14
14
  end
15
15
 
16
- it "returns false when manifest is older" do
16
+ it "returns false when the manifest is older" do
17
17
  latest_timestamp = manifest_timestamp + 3600
18
18
 
19
19
  with_stubs(latest_timestamp: latest_timestamp.to_i) do
@@ -21,7 +21,7 @@ describe "Shakapacker::MtimeStrategy" do
21
21
  end
22
22
  end
23
23
 
24
- it "returns true when manifest is new" do
24
+ it "returns true when the manifest is new" do
25
25
  latest_timestamp = manifest_timestamp - 3600
26
26
 
27
27
  with_stubs(latest_timestamp: latest_timestamp.to_i) do