Skip to content

Commit 1eb1403

Browse files
justin808claude
andcommitted
Fix test failures: restore PackerUtils logic and update bin/dev tests
- Restore proper PackerUtils.using_packer? logic from master branch - Fix precompile? method to handle missing shakapacker properly - Update bin/dev tests to match new simplified template structure - Update server_manager_spec to expect Open3.capture3 instead of system 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4141a39 commit 1eb1403

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

lib/react_on_rails/packer_utils.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33
module ReactOnRails
44
module PackerUtils
55
def self.using_packer?
6-
true
6+
using_shakapacker_const?
7+
end
8+
9+
def self.using_shakapacker_const?
10+
return @using_shakapacker_const if defined?(@using_shakapacker_const)
11+
12+
@using_shakapacker_const = ReactOnRails::Utils.gem_available?("shakapacker") &&
13+
shakapacker_version_requirement_met?("8.2.0")
714
end
815

916
def self.packer_type
10-
"shakapacker"
17+
return "shakapacker" if using_shakapacker_const?
18+
19+
nil
1120
end
1221

1322
def self.packer
@@ -84,7 +93,9 @@ def self.asset_uri_from_packer(asset_name)
8493
end
8594

8695
def self.precompile?
87-
::Shakapacker.config.shakapacker_precompile?
96+
return ::Shakapacker.config.shakapacker_precompile? if using_shakapacker_const?
97+
98+
false
8899
end
89100

90101
def self.packer_source_path

spec/react_on_rails/binstubs/dev_spec.rb

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "react_on_rails/dev"
44

55
RSpec.describe "bin/dev script" do
6-
let(:script_path) { "lib/generators/react_on_rails/bin/dev" }
6+
let(:script_path) { "lib/generators/react_on_rails/templates/base/base/bin/dev" }
77

88
# To suppress stdout during tests
99
original_stderr = $stderr
@@ -40,36 +40,20 @@ def setup_script_execution_for_tool_tests
4040
expect(script_content).to include("require \"react_on_rails/dev\"")
4141
end
4242

43-
it "supports static development mode" do
43+
it "delegates to ServerManager command line interface" do
4444
script_content = File.read(script_path)
45-
expect(script_content).to include("ReactOnRails::Dev::ServerManager.start(:static")
46-
end
47-
48-
it "supports production-like mode" do
49-
script_content = File.read(script_path)
50-
expect(script_content).to include("ReactOnRails::Dev::ServerManager.start(:production_like")
51-
end
52-
53-
it "supports help command" do
54-
script_content = File.read(script_path)
55-
expect(script_content).to include('when "help", "--help", "-h"')
56-
expect(script_content).to include("ReactOnRails::Dev::ServerManager.show_help")
57-
end
58-
59-
it "supports kill command" do
60-
script_content = File.read(script_path)
61-
expect(script_content).to include("ReactOnRails::Dev::ServerManager.kill_processes")
45+
expect(script_content).to include("ReactOnRails::Dev::ServerManager.run_from_command_line")
6246
end
6347

6448
it "with ReactOnRails::Dev loaded, delegates to ServerManager" do
6549
setup_script_execution_for_tool_tests
66-
allow(ReactOnRails::Dev::ServerManager).to receive(:start)
50+
allow(ReactOnRails::Dev::ServerManager).to receive(:run_from_command_line)
6751

6852
# Mock the require to succeed
6953
allow_any_instance_of(Kernel).to receive(:require).with("bundler/setup").and_return(true)
7054
allow_any_instance_of(Kernel).to receive(:require).with("react_on_rails/dev").and_return(true)
7155

72-
expect(ReactOnRails::Dev::ServerManager).to receive(:start).with(:development, "Procfile.dev")
56+
expect(ReactOnRails::Dev::ServerManager).to receive(:run_from_command_line).with(ARGV)
7357

7458
load script_path
7559
end

spec/react_on_rails/dev/server_manager_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def mock_system_calls
5454
end
5555

5656
it "starts production-like mode" do
57-
command = "RAILS_ENV=production NODE_ENV=production bundle exec rails assets:precompile"
58-
expect_any_instance_of(Kernel).to receive(:system).with(command).and_return(true)
57+
command = "NODE_ENV=production bundle exec rails assets:precompile"
58+
expect(Open3).to receive(:capture3).with(command).and_return(["output", "", double(success?: true)])
5959
expect(ReactOnRails::Dev::ProcessManager).to receive(:ensure_procfile).with("Procfile.dev-prod-assets")
6060
expect(ReactOnRails::Dev::ProcessManager).to receive(:run_with_process_manager).with("Procfile.dev-prod-assets")
6161

0 commit comments

Comments
 (0)