Skip to content

Commit aff8a7a

Browse files
justin808claude
andcommitted
Revert be_positive back to be > 0 for compatibility
The be_positive matcher is not available in the RSpec version used with generator_spec test cases. It causes a method_missing error when used within GeneratorSpec::TestCase context. Reverts to the original 'be > 0' syntax which works across all RSpec versions and test contexts. Adds RuboCop disable directive with explanation to prevent future auto-corrections. Fixes test failures: - NoMethodError: undefined method 'be_positive' for GeneratorSpec::TestCase 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 55fa335 commit aff8a7a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

react_on_rails/spec/react_on_rails/generators/js_dependency_manager_spec.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
require_relative "../support/generator_spec_helper"
44

5+
# rubocop:disable Style/NumericPredicate
6+
# Using `be > 0` instead of `be_positive` because `be_positive` is not available
7+
# in the RSpec version used with generator_spec test cases (method_missing conflict)
58
describe ReactOnRails::Generators::JsDependencyManager, type: :generator do
69
# Create a test class that includes the module for testing
710
let(:test_class) do
@@ -182,7 +185,7 @@ def errors
182185
result = instance.send(:install_js_dependencies)
183186

184187
expect(result).to be(false)
185-
expect(warnings.size).to be_positive
188+
expect(warnings.size).to be > 0
186189
expect(warnings.first.to_s).to include("package_json not available")
187190
end
188191

@@ -192,7 +195,7 @@ def errors
192195
result = instance.send(:install_js_dependencies)
193196

194197
expect(result).to be(false)
195-
expect(warnings.size).to be_positive
198+
expect(warnings.size).to be > 0
196199
expect(warnings.first.to_s).to include("JavaScript dependencies installation failed")
197200
end
198201
end
@@ -265,7 +268,7 @@ def errors
265268

266269
instance.send(:add_react_on_rails_package)
267270

268-
expect(warnings.size).to be_positive
271+
expect(warnings.size).to be > 0
269272
expect(warnings.first.to_s).to include("Failed to add react-on-rails package")
270273
end
271274

@@ -274,7 +277,7 @@ def errors
274277

275278
instance.send(:add_react_on_rails_package)
276279

277-
expect(warnings.size).to be_positive
280+
expect(warnings.size).to be > 0
278281
# When add_package catches exception, it returns false, triggering the "Failed to add" warning
279282
expect(warnings.first.to_s).to include("Failed to add react-on-rails package")
280283
end
@@ -291,7 +294,7 @@ def errors
291294

292295
instance.send(:add_react_dependencies)
293296

294-
expect(warnings.size).to be_positive
297+
expect(warnings.size).to be > 0
295298
expect(warnings.first.to_s).to include("Failed to add React dependencies")
296299
end
297300
end
@@ -307,7 +310,7 @@ def errors
307310

308311
instance.send(:add_css_dependencies)
309312

310-
expect(warnings.size).to be_positive
313+
expect(warnings.size).to be > 0
311314
expect(warnings.first.to_s).to include("Failed to add CSS dependencies")
312315
end
313316
end
@@ -336,7 +339,7 @@ def errors
336339

337340
instance.send(:add_dev_dependencies)
338341

339-
expect(warnings.size).to be_positive
342+
expect(warnings.size).to be > 0
340343
expect(warnings.first.to_s).to include("Failed to add development dependencies")
341344
end
342345
end
@@ -352,7 +355,7 @@ def errors
352355

353356
instance.send(:add_rspack_dependencies)
354357

355-
expect(warnings.size).to be_positive
358+
expect(warnings.size).to be > 0
356359
expect(warnings.first.to_s).to include("Failed to add Rspack dependencies")
357360
end
358361
end
@@ -369,7 +372,7 @@ def errors
369372

370373
instance.send(:add_typescript_dependencies)
371374

372-
expect(warnings.size).to be_positive
375+
expect(warnings.size).to be > 0
373376
expect(warnings.first.to_s).to include("Failed to add TypeScript dependencies")
374377
end
375378
end
@@ -413,7 +416,7 @@ def errors
413416
expect { instance.send(:setup_js_dependencies) }.not_to raise_error
414417

415418
# Should have generated warnings for failures
416-
expect(warnings.size).to be_positive
419+
expect(warnings.size).to be > 0
417420
# But no errors that would crash the generator
418421
expect(errors.size).to eq(0)
419422
end
@@ -430,3 +433,4 @@ def errors
430433
end
431434
end
432435
end
436+
# rubocop:enable Style/NumericPredicate

0 commit comments

Comments
 (0)