shakapacker 8.0.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/dummy.yml +1 -1
- data/.github/workflows/generator.yml +5 -1
- data/.github/workflows/node.yml +1 -1
- data/.github/workflows/ruby.yml +8 -2
- data/.gitignore +0 -1
- data/.node-version +1 -1
- data/CHANGELOG.md +21 -12
- data/Gemfile.lock +257 -0
- data/README.md +11 -12
- data/docs/customizing_babel_config.md +32 -4
- data/docs/react.md +3 -2
- data/docs/troubleshooting.md +1 -1
- data/docs/v8_upgrade.md +2 -2
- data/lib/shakapacker/version.rb +1 -1
- data/package.json +2 -2
- data/shakapacker.gemspec +5 -2
- metadata +5 -235
- data/lib/install/bin/yarn +0 -18
- data/rakelib/release.rake +0 -65
- data/spec/dummy/.browserslistrc +0 -1
- data/spec/dummy/.gitignore +0 -20
- data/spec/dummy/.prettierrc.yaml +0 -4
- data/spec/dummy/Gemfile +0 -61
- data/spec/dummy/Procfile.dev +0 -5
- data/spec/dummy/Procfile.dev-static +0 -9
- data/spec/dummy/README.md +0 -1
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/config/manifest.js +0 -2
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/hello_world_controller.rb +0 -9
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/javascript/Globals.d.ts +0 -3
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +0 -25
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +0 -47
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx +0 -5
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg +0 -7
- data/spec/dummy/app/javascript/packs/application.js +0 -17
- data/spec/dummy/app/javascript/packs/hello-world-bundle.ts +0 -8
- data/spec/dummy/app/javascript/packs/server-bundle.ts +0 -8
- data/spec/dummy/app/jobs/application_job.rb +0 -7
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/hello_world/index.html.erb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/app/views/layouts/hello_world.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/babel.config.js +0 -30
- data/spec/dummy/bin/bundle +0 -114
- data/spec/dummy/bin/dev +0 -30
- data/spec/dummy/bin/dev-static +0 -30
- data/spec/dummy/bin/rails +0 -9
- data/spec/dummy/bin/rake +0 -9
- data/spec/dummy/bin/setup +0 -33
- data/spec/dummy/bin/shakapacker +0 -13
- data/spec/dummy/bin/shakapacker-dev-server +0 -13
- data/spec/dummy/bin/spring +0 -17
- data/spec/dummy/bin/yarn +0 -18
- data/spec/dummy/config/application.rb +0 -35
- data/spec/dummy/config/boot.rb +0 -4
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/credentials.yml.enc +0 -1
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -54
- data/spec/dummy/config/environments/production.rb +0 -106
- data/spec/dummy/config/environments/test.rb +0 -49
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/content_security_policy.rb +0 -28
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/react_on_rails.rb +0 -58
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -33
- data/spec/dummy/config/puma.rb +0 -38
- data/spec/dummy/config/routes.rb +0 -6
- data/spec/dummy/config/shakapacker.yml +0 -61
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config/storage.yml +0 -34
- data/spec/dummy/config/webpack/ServerClientOrBoth.js +0 -34
- data/spec/dummy/config/webpack/clientWebpackConfig.js +0 -15
- data/spec/dummy/config/webpack/commonWebpackConfig.js +0 -17
- data/spec/dummy/config/webpack/development.js +0 -32
- data/spec/dummy/config/webpack/production.js +0 -9
- data/spec/dummy/config/webpack/serverWebpackConfig.js +0 -116
- data/spec/dummy/config/webpack/test.js +0 -7
- data/spec/dummy/config/webpack/webpack.config.js +0 -24
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/package.json +0 -44
- data/spec/dummy/postcss.config.js +0 -12
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +0 -1
- data/spec/dummy/spec/rails_helper.rb +0 -118
- data/spec/dummy/spec/spec_helper.rb +0 -96
- data/spec/dummy/spec/system/hello_world_spec.rb +0 -19
- data/spec/dummy/tsconfig.json +0 -21
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/dummy/yarn.lock +0 -4696
- data/spec/fixtures/beta_package-lock.v1.json +0 -119
- data/spec/fixtures/beta_package-lock.v2.json +0 -6777
- data/spec/fixtures/beta_package.json +0 -13
- data/spec/fixtures/beta_pnpm-lock.v7.yaml +0 -116
- data/spec/fixtures/beta_pnpm-lock.v8.yaml +0 -2537
- data/spec/fixtures/beta_pnpm-lock.v9.yaml +0 -2885
- data/spec/fixtures/beta_yarn.v1.lock +0 -106
- data/spec/fixtures/beta_yarn.v2.lock +0 -164
- data/spec/fixtures/git_url_package-lock.v1.json +0 -118
- data/spec/fixtures/git_url_package-lock.v2.json +0 -10263
- data/spec/fixtures/git_url_package.json +0 -13
- data/spec/fixtures/git_url_pnpm-lock.v7.yaml +0 -126
- data/spec/fixtures/git_url_pnpm-lock.v8.yaml +0 -3728
- data/spec/fixtures/git_url_pnpm-lock.v9.yaml +0 -4544
- data/spec/fixtures/git_url_yarn.v1.lock +0 -106
- data/spec/fixtures/git_url_yarn.v2.lock +0 -165
- data/spec/fixtures/github_url_package-lock.v1.json +0 -118
- data/spec/fixtures/github_url_package-lock.v2.json +0 -10263
- data/spec/fixtures/github_url_package.json +0 -13
- data/spec/fixtures/github_url_pnpm-lock.v7.yaml +0 -126
- data/spec/fixtures/github_url_pnpm-lock.v8.yaml +0 -3728
- data/spec/fixtures/github_url_pnpm-lock.v9.yaml +0 -4544
- data/spec/fixtures/github_url_yarn.v1.lock +0 -105
- data/spec/fixtures/github_url_yarn.v2.lock +0 -165
- data/spec/fixtures/relative_path_package-lock.v1.json +0 -3468
- data/spec/fixtures/relative_path_package-lock.v2.json +0 -105
- data/spec/fixtures/relative_path_package.json +0 -13
- data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +0 -18
- data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +0 -22
- data/spec/fixtures/relative_path_pnpm-lock.v9.yaml +0 -28
- data/spec/fixtures/relative_path_yarn.v1.lock +0 -104
- data/spec/fixtures/relative_path_yarn.v2.lock +0 -165
- data/spec/fixtures/semver_caret_package-lock.v1.json +0 -119
- data/spec/fixtures/semver_caret_package-lock.v2.json +0 -10264
- data/spec/fixtures/semver_caret_package.json +0 -13
- data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +0 -117
- data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +0 -2558
- data/spec/fixtures/semver_caret_pnpm-lock.v9.yaml +0 -4285
- data/spec/fixtures/semver_caret_yarn.v1.lock +0 -106
- data/spec/fixtures/semver_caret_yarn.v2.lock +0 -165
- data/spec/fixtures/semver_exact_package-lock.v1.json +0 -119
- data/spec/fixtures/semver_exact_package-lock.v2.json +0 -6819
- data/spec/fixtures/semver_exact_package.json +0 -13
- data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +0 -117
- data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +0 -2558
- data/spec/fixtures/semver_exact_pnpm-lock.v9.yaml +0 -2908
- data/spec/fixtures/semver_exact_yarn.v1.lock +0 -106
- data/spec/fixtures/semver_exact_yarn.v2.lock +0 -165
- data/spec/fixtures/semver_tilde_package-lock.v1.json +0 -119
- data/spec/fixtures/semver_tilde_package-lock.v2.json +0 -6777
- data/spec/fixtures/semver_tilde_package.json +0 -13
- data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +0 -116
- data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +0 -2558
- data/spec/fixtures/semver_tilde_pnpm-lock.v9.yaml +0 -2885
- data/spec/fixtures/semver_tilde_yarn.v1.lock +0 -106
- data/spec/fixtures/semver_tilde_yarn.v2.lock +0 -164
- data/spec/fixtures/without_package-lock.v1.json +0 -19
- data/spec/fixtures/without_package-lock.v2.json +0 -47
- data/spec/fixtures/without_package.json +0 -13
- data/spec/fixtures/without_pnpm-lock.v7.yaml +0 -23
- data/spec/fixtures/without_pnpm-lock.v8.yaml +0 -27
- data/spec/fixtures/without_pnpm-lock.v9.yaml +0 -34
- data/spec/fixtures/without_yarn.v1.lock +0 -13
- data/spec/fixtures/without_yarn.v2.lock +0 -29
- data/spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb +0 -4
- data/spec/generator_specs/e2e_template/files/app/javascript/components/App.js +0 -12
- data/spec/generator_specs/e2e_template/files/app/javascript/packs/application.js +0 -10
- data/spec/generator_specs/e2e_template/files/app/views/home/index.html.erb +0 -2
- data/spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb +0 -17
- data/spec/generator_specs/e2e_template/files/config/routes.rb +0 -3
- data/spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb +0 -13
- data/spec/generator_specs/e2e_template/template.rb +0 -29
- data/spec/generator_specs/fake-bin/bun +0 -10
- data/spec/generator_specs/fake-bin/npm +0 -10
- data/spec/generator_specs/fake-bin/pnpm +0 -10
- data/spec/generator_specs/fake-bin/yarn +0 -10
- data/spec/generator_specs/generator_spec.rb +0 -193
- data/spec/mounted_app/Rakefile +0 -4
- data/spec/mounted_app/package.json +0 -1
- data/spec/mounted_app/test/dummy/Rakefile +0 -3
- data/spec/mounted_app/test/dummy/bin/rails +0 -3
- data/spec/mounted_app/test/dummy/bin/rake +0 -3
- data/spec/mounted_app/test/dummy/config/application.rb +0 -10
- data/spec/mounted_app/test/dummy/config/environment.rb +0 -3
- data/spec/mounted_app/test/dummy/config/webpacker.yml +0 -81
- data/spec/mounted_app/test/dummy/config.ru +0 -5
- data/spec/mounted_app/test/dummy/package.json +0 -7
- data/spec/shakapacker/command_spec.rb +0 -134
- data/spec/shakapacker/compiler_spec.rb +0 -57
- data/spec/shakapacker/compiler_strategy_spec.rb +0 -24
- data/spec/shakapacker/configuration_spec.rb +0 -377
- data/spec/shakapacker/dev_server_runner_spec.rb +0 -136
- data/spec/shakapacker/dev_server_spec.rb +0 -118
- data/spec/shakapacker/digest_strategy_spec.rb +0 -59
- data/spec/shakapacker/engine_rake_tasks_spec.rb +0 -50
- data/spec/shakapacker/env_spec.rb +0 -23
- data/spec/shakapacker/helper_spec.rb +0 -243
- data/spec/shakapacker/instance_spec.rb +0 -29
- data/spec/shakapacker/manifest_spec.rb +0 -100
- data/spec/shakapacker/mtime_strategy_spec.rb +0 -55
- data/spec/shakapacker/rake_tasks_spec.rb +0 -85
- data/spec/shakapacker/shakapacker_spec.rb +0 -40
- data/spec/shakapacker/spec_helper_initializer.rb +0 -24
- data/spec/shakapacker/test_app/.gitignore +0 -2
- data/spec/shakapacker/test_app/Rakefile +0 -3
- data/spec/shakapacker/test_app/app/javascript/entrypoints/application.js +0 -10
- data/spec/shakapacker/test_app/app/javascript/entrypoints/generated/something.js +0 -2
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.css +0 -4
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.js +0 -4
- data/spec/shakapacker/test_app/bin/shakapacker +0 -14
- data/spec/shakapacker/test_app/bin/shakapacker-dev-server +0 -14
- data/spec/shakapacker/test_app/config/application.rb +0 -11
- data/spec/shakapacker/test_app/config/environment.rb +0 -4
- data/spec/shakapacker/test_app/config/initializers/inspect_autoload_paths.rb +0 -1
- data/spec/shakapacker/test_app/config/shakapacker.yml +0 -82
- data/spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +0 -83
- data/spec/shakapacker/test_app/config/shakapacker_defaults_fallback.yml +0 -11
- data/spec/shakapacker/test_app/config/shakapacker_manifest_path.yml +0 -79
- data/spec/shakapacker/test_app/config/shakapacker_nested_entries.yml +0 -82
- data/spec/shakapacker/test_app/config/shakapacker_no_precompile.yml +0 -7
- data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +0 -84
- data/spec/shakapacker/test_app/config/shakapacker_public_root.yml +0 -18
- data/spec/shakapacker/test_app/config/webpack/webpack.config.js +0 -0
- data/spec/shakapacker/test_app/config.ru +0 -5
- data/spec/shakapacker/test_app/package.json +0 -14
- data/spec/shakapacker/test_app/public/packs/manifest.json +0 -58
- data/spec/shakapacker/test_app/some.config.js +0 -0
- data/spec/shakapacker/test_app/yarn.lock +0 -11
- data/spec/shakapacker/utils_manager_spec.rb +0 -125
- data/spec/shakapacker/version_checker_spec.rb +0 -1469
- data/spec/shakapacker/webpack_runner_spec.rb +0 -76
- data/spec/spec_helper.rb +0 -100
- data/spec/support/package_json_helpers.rb +0 -19
@@ -1,377 +0,0 @@
|
|
1
|
-
require_relative "spec_helper_initializer"
|
2
|
-
|
3
|
-
describe "Shakapacker::Configuration" do
|
4
|
-
ROOT_PATH = Pathname.new(File.expand_path("./test_app", __dir__))
|
5
|
-
|
6
|
-
context "with standard shakapacker.yml" do
|
7
|
-
let(:config) do
|
8
|
-
Shakapacker::Configuration.new(
|
9
|
-
root_path: ROOT_PATH,
|
10
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker.yml", __dir__)),
|
11
|
-
env: "production"
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "#source_path returns correct path" do
|
16
|
-
source_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/app/javascript").to_s
|
17
|
-
|
18
|
-
expect(config.source_path.to_s).to eq source_path
|
19
|
-
end
|
20
|
-
|
21
|
-
it "#source_entry_path returns correct path" do
|
22
|
-
source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/app/javascript", "entrypoints").to_s
|
23
|
-
|
24
|
-
expect(config.source_entry_path.to_s).to eq source_entry_path
|
25
|
-
end
|
26
|
-
|
27
|
-
it "#public_root_path returns correct path" do
|
28
|
-
public_root_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public").to_s
|
29
|
-
|
30
|
-
expect(config.public_path.to_s).to eq public_root_path
|
31
|
-
end
|
32
|
-
|
33
|
-
it "#public_output_path returns correct path" do
|
34
|
-
public_output_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs").to_s
|
35
|
-
|
36
|
-
expect(config.public_output_path.to_s).to eq public_output_path
|
37
|
-
end
|
38
|
-
|
39
|
-
it "#public_manifest_path returns correct path" do
|
40
|
-
public_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs", "manifest.json").to_s
|
41
|
-
|
42
|
-
expect(config.public_manifest_path.to_s).to eq public_manifest_path
|
43
|
-
end
|
44
|
-
|
45
|
-
it "#manifest_path returns correct path" do
|
46
|
-
manifest_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs", "manifest.json").to_s
|
47
|
-
|
48
|
-
expect(config.manifest_path.to_s).to eq manifest_path
|
49
|
-
end
|
50
|
-
|
51
|
-
it "#cache_path returns correct path" do
|
52
|
-
cache_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/tmp/shakapacker").to_s
|
53
|
-
|
54
|
-
expect(config.cache_path.to_s).to eq cache_path
|
55
|
-
end
|
56
|
-
|
57
|
-
it "#additional_paths returns correct path" do
|
58
|
-
expect(config.additional_paths).to eq ["app/assets", "/etc/yarn", "some.config.js", "app/elm"]
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#cache_manifest?" do
|
62
|
-
it "returns true in production environment" do
|
63
|
-
expect(config.cache_manifest?).to be true
|
64
|
-
end
|
65
|
-
|
66
|
-
it "returns false in development environment" do
|
67
|
-
with_rails_env("development") do
|
68
|
-
expect(Shakapacker.config.cache_manifest?).to be false
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
it "returns false in test environment" do
|
73
|
-
with_rails_env("test") do
|
74
|
-
expect(Shakapacker.config.cache_manifest?).to be false
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#compile?" do
|
80
|
-
it "returns false in production environment" do
|
81
|
-
expect(config.compile?).to be false
|
82
|
-
end
|
83
|
-
|
84
|
-
it "returns true in development environment" do
|
85
|
-
with_rails_env("development") do
|
86
|
-
expect(Shakapacker.config.compile?).to be true
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "returns true in test environment" do
|
91
|
-
with_rails_env("test") do
|
92
|
-
expect(Shakapacker.config.compile?).to be true
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#nested_entries?" do
|
98
|
-
it "returns false in production environment" do
|
99
|
-
expect(config.nested_entries?).to be false
|
100
|
-
end
|
101
|
-
|
102
|
-
it "returns false in development environment" do
|
103
|
-
with_rails_env("development") do
|
104
|
-
expect(Shakapacker.config.nested_entries?).to be false
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
it "returns false in test environment" do
|
109
|
-
with_rails_env("test") do
|
110
|
-
expect(Shakapacker.config.nested_entries?).to be false
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "#ensure_consistent_versioning?" do
|
116
|
-
it "returns true in production environment" do
|
117
|
-
expect(config.ensure_consistent_versioning?).to be true
|
118
|
-
end
|
119
|
-
|
120
|
-
it "returns true in development environment" do
|
121
|
-
with_rails_env("development") do
|
122
|
-
expect(Shakapacker.config.ensure_consistent_versioning?).to be true
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
it "returns true in test environment" do
|
127
|
-
with_rails_env("test") do
|
128
|
-
expect(Shakapacker.config.ensure_consistent_versioning?).to be true
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "#shakapacker_precompile?" do
|
134
|
-
before :each do
|
135
|
-
ENV.delete("SHAKAPACKER_PRECOMPILE")
|
136
|
-
end
|
137
|
-
|
138
|
-
subject { config.shakapacker_precompile? }
|
139
|
-
|
140
|
-
it "returns true when SHAKAPACKER_PRECOMPILE is unset" do
|
141
|
-
is_expected.to be true
|
142
|
-
end
|
143
|
-
|
144
|
-
it "returns false when SHAKAPACKER_PRECOMPILE sets to no" do
|
145
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "no"
|
146
|
-
is_expected.to be false
|
147
|
-
end
|
148
|
-
|
149
|
-
it "returns true when SHAKAPACKER_PRECOMPILE sets to yes" do
|
150
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "yes"
|
151
|
-
is_expected.to be true
|
152
|
-
end
|
153
|
-
|
154
|
-
it "returns false when SHAKAPACKER_PRECOMPILE sets to false" do
|
155
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "false"
|
156
|
-
is_expected.to be false
|
157
|
-
end
|
158
|
-
|
159
|
-
it "returns true when SHAKAPACKER_PRECOMPILE sets to true" do
|
160
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "true"
|
161
|
-
is_expected.to be true
|
162
|
-
end
|
163
|
-
|
164
|
-
it "returns false when SHAKAPACKER_PRECOMPILE sets to n" do
|
165
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "n"
|
166
|
-
is_expected.to be false
|
167
|
-
end
|
168
|
-
|
169
|
-
it "returns true when SHAKAPACKER_PRECOMPILE sets to y" do
|
170
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "y"
|
171
|
-
is_expected.to be true
|
172
|
-
end
|
173
|
-
|
174
|
-
it "returns false when SHAKAPACKER_PRECOMPILE sets to f" do
|
175
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "f"
|
176
|
-
is_expected.to be false
|
177
|
-
end
|
178
|
-
|
179
|
-
it "returns true when SHAKAPACKER_PRECOMPILE sets to t" do
|
180
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "t"
|
181
|
-
is_expected.to be true
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
context "with shakapacker config file containing public_output_path entry" do
|
187
|
-
config = Shakapacker::Configuration.new(
|
188
|
-
root_path: ROOT_PATH,
|
189
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_public_root.yml", __dir__)),
|
190
|
-
env: "production"
|
191
|
-
)
|
192
|
-
|
193
|
-
it "#public_output_path returns correct path" do
|
194
|
-
expected_public_output_path = File.expand_path File.join(File.dirname(__FILE__), "./public/packs").to_s
|
195
|
-
|
196
|
-
expect(config.public_output_path.to_s).to eq expected_public_output_path
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context "with shakapacker config file containing manifest_path entry" do
|
201
|
-
config = Shakapacker::Configuration.new(
|
202
|
-
root_path: ROOT_PATH,
|
203
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_manifest_path.yml", __dir__)),
|
204
|
-
env: "production"
|
205
|
-
)
|
206
|
-
|
207
|
-
it "#manifest_path returns correct expected value" do
|
208
|
-
expected_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "./test_app/app/javascript", "manifest.json").to_s
|
209
|
-
|
210
|
-
expect(config.manifest_path.to_s).to eq expected_manifest_path
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
context "with shakapacker_precompile entry set to false" do
|
215
|
-
describe "#shakapacker_precompile?" do
|
216
|
-
before :each do
|
217
|
-
ENV.delete("SHAKAPACKER_PRECOMPILE")
|
218
|
-
end
|
219
|
-
|
220
|
-
let(:config) {
|
221
|
-
Shakapacker::Configuration.new(
|
222
|
-
root_path: ROOT_PATH,
|
223
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_no_precompile.yml", __dir__)),
|
224
|
-
env: "production"
|
225
|
-
)
|
226
|
-
}
|
227
|
-
|
228
|
-
subject { config.shakapacker_precompile? }
|
229
|
-
|
230
|
-
it "returns false with unset SHAKAPACKER_PRECOMPILE" do
|
231
|
-
expect(subject).to be false
|
232
|
-
end
|
233
|
-
|
234
|
-
it "returns true with SHAKAPACKER_PRECOMPILE set to true" do
|
235
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = "true"
|
236
|
-
expect(subject).to be true
|
237
|
-
end
|
238
|
-
|
239
|
-
it "returns false with SHAKAPACKER_PRECOMPILE set to nil" do
|
240
|
-
ENV["SHAKAPACKER_PRECOMPILE"] = nil
|
241
|
-
expect(subject).to be false
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
context "with shakapacker config file containing invalid path" do
|
247
|
-
config = Shakapacker::Configuration.new(
|
248
|
-
root_path: ROOT_PATH,
|
249
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/invalid_path.yml", __dir__)),
|
250
|
-
env: "default"
|
251
|
-
)
|
252
|
-
|
253
|
-
it "#shakapacker_precompile? returns false" do
|
254
|
-
expect(config.shakapacker_precompile?).to be false
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
context "with shakapacker config file with defaults fallback" do
|
259
|
-
let(:config) do
|
260
|
-
Shakapacker::Configuration.new(
|
261
|
-
root_path: ROOT_PATH,
|
262
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_defaults_fallback.yml", __dir__)),
|
263
|
-
env: "default"
|
264
|
-
)
|
265
|
-
end
|
266
|
-
|
267
|
-
it "#cache_manifest? falls back to 'default' config from bundled file" do
|
268
|
-
expect(config.cache_manifest?).to be false
|
269
|
-
end
|
270
|
-
|
271
|
-
it "#shakapacker_precompile? uses 'default' config from custom file" do
|
272
|
-
expect(config.shakapacker_precompile?).to be false
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
context "falls back to bundled production config for custom environments" do
|
277
|
-
let(:config) do
|
278
|
-
Shakapacker::Configuration.new(
|
279
|
-
root_path: ROOT_PATH,
|
280
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_defaults_fallback.yml", __dir__)),
|
281
|
-
env: "staging"
|
282
|
-
)
|
283
|
-
end
|
284
|
-
|
285
|
-
it "#cache_manifest? fall back to 'production' config from bundled file" do
|
286
|
-
expect(config.cache_manifest?).to be true
|
287
|
-
end
|
288
|
-
|
289
|
-
it "#shakapacker_precompile? use 'staging' config from custom file" do
|
290
|
-
expect(config.shakapacker_precompile?).to be false
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
context "#source_entry_path" do
|
295
|
-
let(:config) do
|
296
|
-
Shakapacker::Configuration.new(
|
297
|
-
root_path: ROOT_PATH,
|
298
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker.yml", __dir__)),
|
299
|
-
env: "production"
|
300
|
-
)
|
301
|
-
end
|
302
|
-
|
303
|
-
it "returns correct path with source_entry_path starting with 'extra_path'" do
|
304
|
-
allow(config).to receive(:fetch).with(:source_path).and_return("the_source_path")
|
305
|
-
allow(config).to receive(:fetch).with(:source_entry_path).and_return("extra_path")
|
306
|
-
|
307
|
-
actual = config.source_entry_path.to_s
|
308
|
-
expected = "#{config.source_path.to_s}/extra_path"
|
309
|
-
|
310
|
-
expect(actual).to eq(expected)
|
311
|
-
end
|
312
|
-
|
313
|
-
it "returns correct path with source_entry_path starting with /" do
|
314
|
-
allow(config).to receive(:fetch).with(:source_path).and_return("the_source_path")
|
315
|
-
allow(config).to receive(:fetch).with(:source_entry_path).and_return("/")
|
316
|
-
|
317
|
-
actual = config.source_entry_path.to_s
|
318
|
-
expected = config.source_path.to_s
|
319
|
-
|
320
|
-
expect(actual).to eq(expected)
|
321
|
-
end
|
322
|
-
|
323
|
-
it "returns correct path with source_entry_path starting with /extra_path" do
|
324
|
-
allow(config).to receive(:fetch).with(:source_path).and_return("the_source_path")
|
325
|
-
allow(config).to receive(:fetch).with(:source_entry_path).and_return("/extra_path")
|
326
|
-
|
327
|
-
actual = config.source_entry_path.to_s
|
328
|
-
expected = "#{config.source_path.to_s}/extra_path"
|
329
|
-
|
330
|
-
expect(actual).to eq(expected)
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
describe "#asset_host" do
|
335
|
-
let(:config) do
|
336
|
-
Shakapacker::Configuration.new(
|
337
|
-
root_path: ROOT_PATH,
|
338
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker.yml", __dir__)),
|
339
|
-
env: "production"
|
340
|
-
)
|
341
|
-
end
|
342
|
-
|
343
|
-
it "returns the value of SHAKAPACKER_ASSET_HOST if set" do
|
344
|
-
expect(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("custom_host.abc")
|
345
|
-
|
346
|
-
expect(config.asset_host).to eq "custom_host.abc"
|
347
|
-
end
|
348
|
-
|
349
|
-
context "without SHAKAPACKER_ASSET_HOST set" do
|
350
|
-
it "returns asset_host in shakapacker.yml if set" do
|
351
|
-
expect(config).to receive(:fetch).with(:asset_host).and_return("value-in-config-file.com")
|
352
|
-
expect(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", "value-in-config-file.com").and_return("value-in-config-file.com")
|
353
|
-
|
354
|
-
expect(config.asset_host).to eq "value-in-config-file.com"
|
355
|
-
end
|
356
|
-
|
357
|
-
context "without asset_host set in the shakapacker.yml" do
|
358
|
-
it "returns ActionController::Base.helpers.compute_asset_host if SHAKAPACKER_ASSET_HOST is not set" do
|
359
|
-
expect(config).to receive(:fetch).with(:asset_host).and_return(nil)
|
360
|
-
expect(ActionController::Base.helpers).to receive(:compute_asset_host).and_return("domain.abc")
|
361
|
-
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", "domain.abc").and_return("domain.abc")
|
362
|
-
|
363
|
-
expect(config.asset_host).to eq "domain.abc"
|
364
|
-
end
|
365
|
-
|
366
|
-
context "without ActionController::Base.helpers.compute_asset_host returing any value" do
|
367
|
-
it "returns nil" do
|
368
|
-
expect(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return(nil)
|
369
|
-
|
370
|
-
expect(config.asset_host).to be nil
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
end
|
@@ -1,136 +0,0 @@
|
|
1
|
-
require_relative "spec_helper_initializer"
|
2
|
-
require "shakapacker/dev_server_runner"
|
3
|
-
|
4
|
-
describe "DevServerRunner" do
|
5
|
-
around do |example|
|
6
|
-
within_temp_directory do
|
7
|
-
FileUtils.cp_r(File.expand_path("./test_app", __dir__), Dir.pwd)
|
8
|
-
Dir.chdir("test_app") { example.run }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
before do
|
13
|
-
@original_node_env, ENV["NODE_ENV"] = ENV["NODE_ENV"], "development"
|
14
|
-
@original_rails_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "development"
|
15
|
-
@original_shakapacker_config = ENV["SHAKAPACKER_CONFIG"]
|
16
|
-
end
|
17
|
-
|
18
|
-
after do
|
19
|
-
ENV["NODE_ENV"] = @original_node_env
|
20
|
-
ENV["RAILS_ENV"] = @original_rails_env
|
21
|
-
ENV["SHAKAPACKER_CONFIG"] = @original_shakapacker_config
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:test_app_path) { Dir.pwd }
|
25
|
-
|
26
|
-
NODE_PACKAGE_MANAGERS.each do |fallback_manager|
|
27
|
-
context "when using package_json with #{fallback_manager} as the manager" do
|
28
|
-
before do
|
29
|
-
manager_name = fallback_manager.split("_")[0]
|
30
|
-
manager_version = "1.2.3"
|
31
|
-
manager_version = "4.5.6" if fallback_manager == "yarn_berry"
|
32
|
-
|
33
|
-
PackageJson.read.merge! { { "packageManager" => "#{manager_name}@#{manager_version}" } }
|
34
|
-
|
35
|
-
allow(Shakapacker::Utils::Manager).to receive(:error_unless_package_manager_is_obvious!)
|
36
|
-
end
|
37
|
-
|
38
|
-
let(:package_json) { PackageJson.read(test_app_path) }
|
39
|
-
|
40
|
-
it "uses the expected package manager", unless: fallback_manager == "yarn_classic" do
|
41
|
-
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
42
|
-
|
43
|
-
manager_name = fallback_manager.split("_")[0]
|
44
|
-
|
45
|
-
expect(cmd).to start_with(manager_name)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "runs the command using the manager" do
|
49
|
-
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
50
|
-
|
51
|
-
verify_command(cmd)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "passes on arguments" do
|
55
|
-
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--quiet"])
|
56
|
-
|
57
|
-
verify_command(cmd, argv: (["--quiet"]))
|
58
|
-
end
|
59
|
-
|
60
|
-
it "does not automatically pass the --https flag" do
|
61
|
-
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
62
|
-
|
63
|
-
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
64
|
-
double(
|
65
|
-
host: "localhost",
|
66
|
-
port: "3035",
|
67
|
-
pretty?: false,
|
68
|
-
protocol: "https",
|
69
|
-
hmr?: true
|
70
|
-
)
|
71
|
-
)
|
72
|
-
|
73
|
-
verify_command(cmd)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "supports the https flag" do
|
77
|
-
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--https"])
|
78
|
-
|
79
|
-
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
80
|
-
double(
|
81
|
-
host: "localhost",
|
82
|
-
port: "3035",
|
83
|
-
pretty?: false,
|
84
|
-
protocol: "https",
|
85
|
-
hmr?: true
|
86
|
-
)
|
87
|
-
)
|
88
|
-
|
89
|
-
verify_command(cmd, argv: ["--https"])
|
90
|
-
end
|
91
|
-
|
92
|
-
it "supports disabling hot module reloading" do
|
93
|
-
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--no-hot"])
|
94
|
-
|
95
|
-
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
96
|
-
double(
|
97
|
-
host: "localhost",
|
98
|
-
port: "3035",
|
99
|
-
pretty?: false,
|
100
|
-
protocol: "http",
|
101
|
-
hmr?: false
|
102
|
-
)
|
103
|
-
)
|
104
|
-
|
105
|
-
verify_command(cmd)
|
106
|
-
end
|
107
|
-
|
108
|
-
it "accepts environment variables" do
|
109
|
-
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
110
|
-
|
111
|
-
env = Shakapacker::Compiler.env.dup
|
112
|
-
ENV["SHAKAPACKER_CONFIG"] = env["SHAKAPACKER_CONFIG"] = "#{test_app_path}/config/shakapacker_other_location.yml"
|
113
|
-
env["WEBPACK_SERVE"] = "true"
|
114
|
-
|
115
|
-
verify_command(cmd, env: env)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
|
122
|
-
def verify_command(cmd, argv: [], env: Shakapacker::Compiler.env)
|
123
|
-
Dir.chdir(test_app_path) do
|
124
|
-
klass = Shakapacker::DevServerRunner
|
125
|
-
instance = klass.new(argv)
|
126
|
-
|
127
|
-
allow(klass).to receive(:new).and_return(instance)
|
128
|
-
allow(Kernel).to receive(:exec).with(env, *cmd)
|
129
|
-
|
130
|
-
klass.run(argv)
|
131
|
-
|
132
|
-
expect(Kernel).to have_received(:exec).with(env, *cmd)
|
133
|
-
expect(Shakapacker::Utils::Manager).to have_received(:error_unless_package_manager_is_obvious!)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require_relative "spec_helper_initializer"
|
2
|
-
|
3
|
-
describe "DevServer" do
|
4
|
-
it "doesn't run by default" do
|
5
|
-
expect(Shakapacker.dev_server.running?).to be_falsy
|
6
|
-
end
|
7
|
-
|
8
|
-
it "uses localhost as host in development environment" do
|
9
|
-
with_rails_env("development") do
|
10
|
-
expect(Shakapacker.dev_server.host).to eq "localhost"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "uses port 3035 in development environment" do
|
15
|
-
with_rails_env("development") do
|
16
|
-
expect(Shakapacker.dev_server.port).to eq 3035
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "uses http protocol in development environment" do
|
21
|
-
with_rails_env("development") do
|
22
|
-
expect(Shakapacker.dev_server.protocol).to eq "http"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "sets host_with_port to localhost:3035 in development environment" do
|
27
|
-
with_rails_env("development") do
|
28
|
-
expect(Shakapacker.dev_server.host_with_port).to eq "localhost:3035"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it "doesn't use pretty in development environment" do
|
33
|
-
with_rails_env("development") do
|
34
|
-
expect(Shakapacker.dev_server.pretty?).to be false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "uses SHAKAPACKER_DEV_SERVER for DEFAULT_ENV_PREFIX" do
|
39
|
-
expect(Shakapacker::DevServer::DEFAULT_ENV_PREFIX).to eq "SHAKAPACKER_DEV_SERVER"
|
40
|
-
end
|
41
|
-
|
42
|
-
context "#protocol in development environment" do
|
43
|
-
let(:dev_server) { Shakapacker.dev_server }
|
44
|
-
|
45
|
-
it "returns `http` by default (with unset `server`)" do
|
46
|
-
with_rails_env("development") do
|
47
|
-
expect(dev_server.protocol).to eq "http"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it "returns `https` when `server` is set to `https`" do
|
52
|
-
expect(dev_server).to receive(:server).and_return("https")
|
53
|
-
|
54
|
-
with_rails_env("development") do
|
55
|
-
expect(dev_server.protocol).to eq "https"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "#server in development environment" do
|
61
|
-
let(:dev_server) { Shakapacker.dev_server }
|
62
|
-
|
63
|
-
it "returns `http` when unset" do
|
64
|
-
expect(dev_server).to receive(:fetch).with(:server).and_return(nil)
|
65
|
-
|
66
|
-
with_rails_env("development") do
|
67
|
-
expect(dev_server.server).to eq "http"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns `http` when set to `https`" do
|
72
|
-
expect(dev_server).to receive(:fetch).with(:server).and_return("http")
|
73
|
-
|
74
|
-
with_rails_env("development") do
|
75
|
-
expect(dev_server.server).to eq "http"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
it "returns `http` when set to a hash with `type: http`" do
|
80
|
-
expect(dev_server).to receive(:fetch).with(:server).and_return({
|
81
|
-
type: "http",
|
82
|
-
options: {}
|
83
|
-
})
|
84
|
-
|
85
|
-
with_rails_env("development") do
|
86
|
-
expect(dev_server.server).to eq "http"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "returns `https` when set to `https`" do
|
91
|
-
expect(dev_server).to receive(:fetch).with(:server).and_return("https")
|
92
|
-
|
93
|
-
with_rails_env("development") do
|
94
|
-
expect(dev_server.server).to eq "https"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
it "returns `https` when set to a hash with `type: https`" do
|
99
|
-
expect(dev_server).to receive(:fetch).with(:server).and_return({
|
100
|
-
type: "https",
|
101
|
-
options: {}
|
102
|
-
})
|
103
|
-
|
104
|
-
with_rails_env("development") do
|
105
|
-
expect(dev_server.server).to eq "https"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
it "returns `http` when set to any value except `http` and `https`" do
|
110
|
-
expect(dev_server).to receive(:fetch).twice.with(:server).and_return("other-than-https")
|
111
|
-
|
112
|
-
with_rails_env("development") do
|
113
|
-
expect(dev_server.server).to eq "http"
|
114
|
-
expect { dev_server.server }.to output(/WARNING/).to_stdout
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require_relative "spec_helper_initializer"
|
2
|
-
|
3
|
-
describe "DigestStrategy" do
|
4
|
-
def remove_compilation_digest_path
|
5
|
-
@digest_strategy.send(:compilation_digest_path).tap do |path|
|
6
|
-
path.delete if path.exist?
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
before :all do
|
11
|
-
@digest_strategy = Shakapacker::DigestStrategy.new
|
12
|
-
remove_compilation_digest_path
|
13
|
-
end
|
14
|
-
|
15
|
-
after :all do
|
16
|
-
remove_compilation_digest_path
|
17
|
-
end
|
18
|
-
|
19
|
-
it "is not fresh before compilation" do
|
20
|
-
expect(@digest_strategy.stale?).to be true
|
21
|
-
expect(@digest_strategy.fresh?).to be_falsy
|
22
|
-
end
|
23
|
-
|
24
|
-
it "is fresh after compilation" do
|
25
|
-
@digest_strategy.after_compile_hook
|
26
|
-
|
27
|
-
expect(@digest_strategy.stale?).to be false
|
28
|
-
expect(@digest_strategy.fresh?).to be true
|
29
|
-
end
|
30
|
-
|
31
|
-
it "is stale when host changes" do
|
32
|
-
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("old-host")
|
33
|
-
# Record the digests for old-host
|
34
|
-
@digest_strategy.after_compile_hook
|
35
|
-
|
36
|
-
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("new-host")
|
37
|
-
expect(@digest_strategy.stale?).to be true
|
38
|
-
expect(@digest_strategy.fresh?).to be_falsey
|
39
|
-
end
|
40
|
-
|
41
|
-
it "generates correct compilation_digest_path" do
|
42
|
-
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("custom-path")
|
43
|
-
|
44
|
-
actual_path = @digest_strategy.send(:compilation_digest_path).basename.to_s
|
45
|
-
host_hash = Digest::SHA1.hexdigest("custom-path")
|
46
|
-
expected_path = "last-compilation-digest-#{Shakapacker.env}"
|
47
|
-
|
48
|
-
expect(actual_path).to eq expected_path
|
49
|
-
end
|
50
|
-
|
51
|
-
it "generates correct compilation_digest_path without the digest of the asset host if asset host is not set" do
|
52
|
-
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return(nil)
|
53
|
-
|
54
|
-
actual_path = @digest_strategy.send(:compilation_digest_path).basename.to_s
|
55
|
-
expected_path = "last-compilation-digest-#{Shakapacker.env}"
|
56
|
-
|
57
|
-
expect(actual_path).to eq expected_path
|
58
|
-
end
|
59
|
-
end
|