Skip to content

Commit 8021316

Browse files
justin808claude
andcommitted
Run RSpec for minimum version examples with bundler isolation
Add unbundled option to run_tests_in to use unbundled_sh_in_dir for minimum version example tests. This ensures the example app's Gemfile and gem versions are used (e.g., Shakapacker 8.2.0) instead of the parent workspace's bundle context (which has Shakapacker 9.4.0). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent a55cdc2 commit 8021316

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

react_on_rails/rakelib/run_rspec.rake

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ namespace :run_rspec do
8181
puts "Creating #{example_type.rspec_task_name} task"
8282
desc "Runs RSpec for #{example_type.name_pretty} only"
8383
task example_type.rspec_task_name_short => example_type.gen_task_name do
84-
run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path
84+
# Use unbundled mode for minimum version examples to ensure the example app's
85+
# Gemfile and gem versions are used, not the parent workspace's bundle
86+
run_tests_in(File.join(examples_dir, example_type.name),
87+
unbundled: example_type.minimum_versions?)
8588
end
8689
end
8790

@@ -157,11 +160,17 @@ end
157160
# If string is passed and it's not absolute, it's converted relative to root of the gem.
158161
# TEST_ENV_COMMAND_NAME is used to make SimpleCov.command_name unique in order to
159162
# prevent a name collision. Defaults to the given directory's name.
163+
# Options:
164+
# :command_name - name for SimpleCov (default: dir basename)
165+
# :rspec_args - additional rspec arguments (default: "")
166+
# :env_vars - additional environment variables (default: "")
167+
# :unbundled - run with unbundled_sh_in_dir for Bundler isolation (default: false)
160168
def run_tests_in(dir, options = {})
161169
path = calc_path(dir)
162170

163171
command_name = options.fetch(:command_name, path.basename)
164172
rspec_args = options.fetch(:rspec_args, "")
173+
unbundled = options.fetch(:unbundled, false)
165174

166175
# Build environment variables as an array for proper spacing
167176
env_tokens = []
@@ -170,5 +179,11 @@ def run_tests_in(dir, options = {})
170179
env_tokens << "COVERAGE=true" if ENV["USE_COVERALLS"]
171180

172181
env_vars = env_tokens.join(" ")
173-
sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
182+
command = "#{env_vars} bundle exec rspec #{rspec_args}"
183+
184+
if unbundled
185+
unbundled_sh_in_dir(path.realpath, command)
186+
else
187+
sh_in_dir(path.realpath, command)
188+
end
174189
end

0 commit comments

Comments
 (0)