Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
### 2.0.0.pre

Version 2.0.0 is a maintenance release, it drops support for Ruby below 3, and
changes the supported RSpec version to "main" and current release series.
(At the time of writing this is 3.13.x, but it means the current supported
release only).
Version 2.0.0 drops support for Ruby below 3, and changes the supported RSpec version to "main" and current release series.
(At the time of writing this is 3.13.x, but it means the current supported release only).

Breaking changes:

* Now uses `public_send` so that private methods will not be accidentally reachable. (James Ottaway #33, #101)

### 1.3.1 / 2024-10-23
[full changelog](http://github.com/rspec/rspec-its/compare/v1.3.0...v1.3.1)
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/its/subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def for(attribute, subject)
else
attribute_chain = attribute.to_s.split('.')
attribute_chain.inject(subject) do |inner_subject, attr|
inner_subject.send(attr)
inner_subject.public_send(attr)
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions spec/rspec/its_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,32 @@ def self.example(*_args)

its(:will_still_work) { is_expected.to be true }
end

context "with private method" do
subject(:klass) do
Class.new do
def name
private_name
end

private

def private_name
"John"
end
end.new
end

context "when referring indirectly" do
its(:name) { is_expected.to eq "John" }
end

context "when attempting to refer directly" do
context "it raises an error" do
its(:private_name) do
expect { is_expected.to eq("John") }.to raise_error(NoMethodError)
end
end
end
end
end
Loading