Skip to content

Commit 0e639f7

Browse files
justin808claude
andcommitted
Fix RuboCop offenses in CSS module tests
- Remove trailing whitespace - Fix line length violations - Add named subject for RSpec compliance - Disable Security/Eval with proper scoping for test validation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3e1b48c commit 0e639f7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

spec/dummy/spec/packs_generator_spec.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,22 +448,26 @@ def create_new_component(name)
448448
it "generates a pack with valid JavaScript variable names" do
449449
expect(File.exist?(component_pack)).to be(true)
450450
pack_content = File.read(component_pack)
451-
451+
452452
# Check that the generated pack content is valid JavaScript
453453
expect(pack_content).to include("import ReactOnRails from 'react-on-rails/client';")
454454
expect(pack_content).to include("import #{component_name} from")
455455
expect(pack_content).to include("ReactOnRails.register({#{component_name}});")
456-
456+
457457
# Verify that variable names don't contain dots (invalid in JS)
458458
expect(pack_content).not_to match(/ComponentWithCSSModule\.module/)
459459
expect(pack_content).not_to match(/import .+\.module/)
460460
end
461461

462462
it "generates valid JavaScript that can be parsed without syntax errors" do
463463
pack_content = File.read(component_pack)
464-
464+
465465
# This would fail if the generated JavaScript has syntax errors
466-
expect { eval(pack_content.gsub(/import.*from.*['"];/, "").gsub(/ReactOnRails\.register.*/, "")) }.not_to raise_error
466+
# rubocop:disable Security/Eval
467+
sanitized_content = pack_content.gsub(/import.*from.*['"];/, "")
468+
.gsub(/ReactOnRails\.register.*/, "")
469+
expect { eval(sanitized_content) }.not_to raise_error
470+
# rubocop:enable Security/Eval
467471
end
468472
end
469473

@@ -691,7 +695,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
691695
end
692696

693697
describe "#component_name" do
694-
subject { described_class.instance.send(:component_name, file_path) }
698+
subject(:component_name) { described_class.instance.send(:component_name, file_path) }
695699

696700
context "with regular component file" do
697701
let(:file_path) { "/path/to/MyComponent.jsx" }
@@ -717,7 +721,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
717721
# CSS modules should still work with component_name method, but they
718722
# should not be processed as React components by the generator
719723
it "returns name with dot for CSS modules" do
720-
expect(subject).to eq "HeavyMarkdownEditor.module"
724+
expect(component_name).to eq "HeavyMarkdownEditor.module"
721725
end
722726
end
723727

0 commit comments

Comments
 (0)