Skip to content

Commit 78bd6aa

Browse files
justin808claude
andcommitted
Fix PackageJson constant NameError in generator_helper_spec
The test was failing with: NameError: uninitialized constant PackageJson This occurred because instance_double(PackageJson) requires the PackageJson constant to be defined at the time the double is created. Solution: Stub the PackageJson constant in the before block before creating the instance_double, consistent with other tests in the same file that use stub_const for PackageJson. This fix resolves all 3 failing tests in CI: - calls manager.add with exact: true - calls manager.add with type: :dev and exact: true - returns false and prints a warning 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 086ba5e commit 78bd6aa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

spec/react_on_rails/generators/generator_helper_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
let(:mock_manager) { instance_double("PackageJson::Manager") } # rubocop:disable RSpec/VerifiedDoubleReference
1414

1515
before do
16+
# Stub PackageJson constant so instance_double can reference it
17+
stub_const("PackageJson", Class.new) unless defined?(PackageJson)
18+
1619
allow(self).to receive(:package_json).and_return(mock_package_json)
1720
allow(mock_package_json).to receive(:manager).and_return(mock_manager)
1821
end

0 commit comments

Comments
 (0)