File tree 3 files changed +35
-5
lines changed
3 files changed +35
-5
lines changed Original file line number Diff line number Diff line change 1
1
### 2.0.0.pre
2
2
3
- Version 2.0.0 is a maintenance release, it drops support for Ruby below 3, and
4
- changes the supported RSpec version to "main" and current release series.
5
- (At the time of writing this is 3.13.x, but it means the current supported
6
- release only).
3
+ Version 2.0.0 drops support for Ruby below 3, and changes the supported RSpec version to "main" and current release series.
4
+ (At the time of writing this is 3.13.x, but it means the current supported release only).
5
+
6
+ Breaking changes:
7
+
8
+ * Now uses ` public_send ` so that private methods will not be accidentally reachable. (James Ottaway #33 , #101 )
7
9
8
10
### 1.3.1 / 2024-10-23
9
11
[ full changelog] ( http://github.com/rspec/rspec-its/compare/v1.3.0...v1.3.1 )
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def for(attribute, subject)
15
15
else
16
16
attribute_chain = attribute . to_s . split ( '.' )
17
17
attribute_chain . inject ( subject ) do |inner_subject , attr |
18
- inner_subject . send ( attr )
18
+ inner_subject . public_send ( attr )
19
19
end
20
20
end
21
21
end
Original file line number Diff line number Diff line change @@ -393,4 +393,32 @@ def self.example(*_args)
393
393
394
394
its ( :will_still_work ) { is_expected . to be true }
395
395
end
396
+
397
+ context "with private method" do
398
+ subject ( :klass ) do
399
+ Class . new do
400
+ def name
401
+ private_name
402
+ end
403
+
404
+ private
405
+
406
+ def private_name
407
+ "John"
408
+ end
409
+ end . new
410
+ end
411
+
412
+ context "when referring indirectly" do
413
+ its ( :name ) { is_expected . to eq "John" }
414
+ end
415
+
416
+ context "when attempting to refer directly" do
417
+ context "it raises an error" do
418
+ its ( :private_name ) do
419
+ expect { is_expected . to eq ( "John" ) } . to raise_error ( NoMethodError )
420
+ end
421
+ end
422
+ end
423
+ end
396
424
end
You can’t perform that action at this time.
0 commit comments