Skip to content

Commit 4ca85b7

Browse files
justin808claude
andcommitted
Fix line length violations in Dev specs
Fixes: - Extract long command strings to variables to reduce line length - Improve readability by making command strings more explicit - Fix RuboCop line length violations in dev specs Changes: - pack_generator_spec.rb: Extract rake command to variable - server_manager_spec.rb: Extract assets:precompile and pgrep commands to variables 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a9aaaaa commit 4ca85b7

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

spec/react_on_rails/dev/pack_generator_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818

1919
describe ".generate" do
2020
it "runs pack generation successfully in verbose mode" do
21-
allow_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs").and_return(true)
21+
command = "bundle exec rake react_on_rails:generate_packs"
22+
allow_any_instance_of(Kernel).to receive(:system).with(command).and_return(true)
2223

2324
expect { described_class.generate(verbose: true) }.not_to raise_error
2425
end
2526

2627
it "runs pack generation successfully in quiet mode" do
27-
allow_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1").and_return(true)
28+
command = "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
29+
allow_any_instance_of(Kernel).to receive(:system).with(command).and_return(true)
2830

2931
expect { described_class.generate(verbose: false) }.not_to raise_error
3032
end
3133

3234
it "exits with error when pack generation fails" do
33-
allow_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1").and_return(false)
35+
command = "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
36+
allow_any_instance_of(Kernel).to receive(:system).with(command).and_return(false)
3437
expect_any_instance_of(Kernel).to receive(:exit).with(1)
3538

3639
described_class.generate(verbose: false)

spec/react_on_rails/dev/server_manager_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def mock_system_calls
5252
end
5353

5454
it "starts production-like mode" do
55-
expect_any_instance_of(Kernel).to receive(:system).with("RAILS_ENV=production NODE_ENV=production bundle exec rails assets:precompile").and_return(true)
55+
command = "RAILS_ENV=production NODE_ENV=production bundle exec rails assets:precompile"
56+
expect_any_instance_of(Kernel).to receive(:system).with(command).and_return(true)
5657
expect(ReactOnRails::Dev::ProcessManager).to receive(:ensure_procfile).with("Procfile.dev-prod-assets")
5758
expect(ReactOnRails::Dev::ProcessManager).to receive(:run_with_process_manager).with("Procfile.dev-prod-assets")
5859

@@ -73,12 +74,14 @@ def mock_system_calls
7374
it "attempts to kill development processes" do
7475
# Mock all the pgrep patterns used in kill_processes
7576
allow_any_instance_of(Kernel).to receive(:`).with("pgrep -f \"rails\" 2>/dev/null").and_return("1234\n5678")
76-
allow_any_instance_of(Kernel).to receive(:`).with("pgrep -f \"node.*react[-_]on[-_]rails\" 2>/dev/null").and_return("2345")
77+
pgrep_cmd = "pgrep -f \"node.*react[-_]on[-_]rails\" 2>/dev/null"
78+
allow_any_instance_of(Kernel).to receive(:`).with(pgrep_cmd).and_return("2345")
7779
allow_any_instance_of(Kernel).to receive(:`).with("pgrep -f \"overmind\" 2>/dev/null").and_return("")
7880
allow_any_instance_of(Kernel).to receive(:`).with("pgrep -f \"foreman\" 2>/dev/null").and_return("")
7981
allow_any_instance_of(Kernel).to receive(:`).with("pgrep -f \"ruby.*puma\" 2>/dev/null").and_return("")
8082
allow_any_instance_of(Kernel).to receive(:`).with("pgrep -f \"webpack-dev-server\" 2>/dev/null").and_return("")
81-
allow_any_instance_of(Kernel).to receive(:`).with("pgrep -f \"bin/shakapacker-dev-server\" 2>/dev/null").and_return("")
83+
shakapacker_cmd = "pgrep -f \"bin/shakapacker-dev-server\" 2>/dev/null"
84+
allow_any_instance_of(Kernel).to receive(:`).with(shakapacker_cmd).and_return("")
8285

8386
allow(Process).to receive(:pid).and_return(9999) # Current process PID
8487
expect(Process).to receive(:kill).with("TERM", 1234)

0 commit comments

Comments
 (0)