Skip to content

Commit 68dad40

Browse files
make utils rspec test run using the packer installed on CI
1 parent 0f9ec1d commit 68dad40

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.github/workflows/rspec-package-specs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
git config user.email "[email protected]"
4848
git config user.name "Your Name"
4949
git commit -am "stop generators from complaining about uncommitted code"
50+
- name: Set packer version environment variable
51+
run: |
52+
echo "CI_PACKER_VERSION=${{ matrix.versions == 'oldest' && 'old' || 'new' }}" >> $GITHUB_ENV
5053
- name: Run rspec tests
5154
run: bundle exec rspec spec/react_on_rails
5255
- name: Store test results

script/convert

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ new_config = File.expand_path("../spec/dummy/config/webpacker.yml", __dir__)
1414
File.rename(old_config, new_config)
1515

1616
gsub_file_content("../Gemfile.development_dependencies", 'gem "shakapacker", "8.0.0"', 'gem "shakapacker", "6.6.0"')
17+
gsub_file_content("../Gemfile.development_dependencies", 'gem "webpacker", "6.0.0.rc.6"', '')
1718

1819
gsub_file_content("../spec/dummy/package.json", '"shakapacker": "8.0.0",', '"shakapacker": "6.6.0",')
1920

spec/react_on_rails/utils_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
# rubocop:disable Metrics/ModuleLength, Metrics/BlockLength
77
module ReactOnRails
88
RSpec.describe Utils do
9+
# Github Actions already run rspec tests two times, once with shakapacker and once with webpacker.
10+
# If rspec tests are run locally, we want to test both packers.
11+
# If rspec tests are run in CI, we want to test the packer specified in the CI_PACKER_VERSION environment variable.
12+
# Check script/convert and .github/workflows/rspec-package-specs.yml for more details.
13+
PACKERS_TO_TEST = if ENV["CI_PACKER_VERSION"] == "old"
14+
["webpacker"]
15+
elsif ENV["CI_PACKER_VERSION"] == "new"
16+
["shakapacker"]
17+
else
18+
["shakapacker", "webpacker"]
19+
end
20+
921
shared_context "with packer enabled" do
1022
before do
1123
allow(ReactOnRails).to receive_message_chain(:configuration, :generated_assets_dir)
@@ -196,7 +208,7 @@ def mock_dev_server_running
196208
end
197209
end
198210

199-
["shakapacker", "webpacker"].each do |packer_type|
211+
PACKERS_TO_TEST.each do |packer_type|
200212
describe ".server_bundle_js_file_path with #{packer_type} enabled" do
201213
let(:packer_public_output_path) { Pathname.new("public/webpack/development") }
202214
include_context "with #{packer_type} enabled"

0 commit comments

Comments
 (0)