Skip to content

Commit 19fbaaa

Browse files
justin808claude
andcommitted
Fix bin/dev NameError by requiring PackerUtils in PackGenerator
Problem: - bin/dev was failing with: uninitialized constant ReactOnRails::PackerUtils (NameError) - pack_generator.rb was using PackerUtils without requiring it - This broke bin/dev for all generated apps and spec/dummy Solution: - Add require_relative "../packer_utils" to pack_generator.rb - Add integration tests to verify all required modules are accessible - Add test to ensure PackerUtils is available when loading react_on_rails/dev Testing: - Added integration test in dev_spec.rb to verify bin/dev dependencies - Added module dependencies test in pack_generator_spec.rb - All tests pass without NameError 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b547ef9 commit 19fbaaa

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

lib/react_on_rails/dev/pack_generator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "English"
44
require "stringio"
5+
require_relative "../packer_utils"
56

67
module ReactOnRails
78
module Dev

spec/react_on_rails/binstubs/dev_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
RSpec.describe "bin/dev script" do
66
let(:script_path) { "lib/generators/react_on_rails/templates/base/base/bin/dev" }
7+
let(:dummy_dev_path) { "spec/dummy/bin/dev" }
78

89
# To suppress stdout during tests
910
original_stderr = $stderr
@@ -58,4 +59,28 @@ def setup_script_execution_for_tool_tests
5859

5960
load script_path
6061
end
62+
63+
# Integration test: verify bin/dev can load without NameError
64+
describe "integration test" do
65+
it "spec/dummy/bin/dev can load the template script without errors" do
66+
# This test verifies that all required dependencies are properly loaded
67+
# when bin/dev is executed, catching issues like missing require statements
68+
expect(File.exist?(dummy_dev_path)).to be true
69+
expect(File.exist?(script_path)).to be true
70+
71+
# Verify the dummy script references the template
72+
dummy_content = File.read(dummy_dev_path)
73+
expect(dummy_content).to include(script_path)
74+
end
75+
76+
it "can require react_on_rails/dev and access all necessary modules" do
77+
# This catches missing require statements in pack_generator.rb and other files
78+
# If PackerUtils isn't required, this would fail with NameError
79+
require "react_on_rails/dev"
80+
81+
expect { ReactOnRails::Dev::ServerManager }.not_to raise_error
82+
expect { ReactOnRails::Dev::PackGenerator }.not_to raise_error
83+
expect { ReactOnRails::PackerUtils }.not_to raise_error
84+
end
85+
end
6186
end

spec/react_on_rails/dev/pack_generator_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
require "react_on_rails/dev/pack_generator"
55

66
RSpec.describe ReactOnRails::Dev::PackGenerator do
7+
# Integration test: verify PackerUtils is properly required
8+
describe "module dependencies" do
9+
it "can access ReactOnRails::PackerUtils without errors" do
10+
# This test ensures the require statement is present in pack_generator.rb
11+
# If the require is missing, this will raise NameError: uninitialized constant
12+
expect { ReactOnRails::PackerUtils }.not_to raise_error
13+
end
14+
end
15+
716
describe ".generate" do
817
context "when shakapacker precompile hook is configured" do
918
before do

0 commit comments

Comments
 (0)