Skip to content

Commit f666831

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 <noreply@anthropic.com>
1 parent 7582e68 commit f666831

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
@@ -82,7 +82,10 @@ namespace :run_rspec do
8282
puts "Creating #{example_type.rspec_task_name} task"
8383
desc "Runs RSpec for #{example_type.name_pretty} only"
8484
task example_type.rspec_task_name_short => example_type.gen_task_name do
85-
run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path
85+
# Use unbundled mode for minimum version examples to ensure the example app's
86+
# Gemfile and gem versions are used, not the parent workspace's bundle
87+
run_tests_in(File.join(examples_dir, example_type.name),
88+
unbundled: example_type.minimum_versions?)
8689
end
8790
end
8891

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

164172
command_name = options.fetch(:command_name, path.basename)
165173
rspec_args = options.fetch(:rspec_args, "")
174+
unbundled = options.fetch(:unbundled, false)
166175

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

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

0 commit comments

Comments
 (0)