Skip to content

Commit f81594d

Browse files
committed
Enforce protected attribute encapsulation in specs
- Add tests to ensure internal attributes (`collection`, `storage`, and `data`) in `Hooks::Collection`, `Settings::Collection`, `RegistrySettings`, and `Settings::Setting` remain inaccessible via public interface. - Verify `NoMethodError` is raised when attempting public access to these protected attributes.
1 parent 4018c77 commit f81594d

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

spec/stroma/hooks/collection_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,10 @@
110110
expect(hooks.map(&:itself)).to all(be_a(Stroma::Hooks::Hook))
111111
end
112112
end
113+
114+
describe "protected interface" do
115+
it "does not expose collection publicly" do
116+
expect { hooks.collection }.to raise_error(NoMethodError)
117+
end
118+
end
113119
end

spec/stroma/settings/collection_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,10 @@
138138
expect(settings[:actions][:transactional][:class]).to eq("ActiveRecord::Base")
139139
end
140140
end
141+
142+
describe "protected interface" do
143+
it "does not expose storage publicly" do
144+
expect { settings.storage }.to raise_error(NoMethodError)
145+
end
146+
end
141147
end

spec/stroma/settings/registry_settings_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,10 @@
109109
expect(settings[:authorization].key?(:new_key)).to be(false)
110110
end
111111
end
112+
113+
describe "protected interface" do
114+
it "does not expose storage publicly" do
115+
expect { settings.storage }.to raise_error(NoMethodError)
116+
end
117+
end
112118
end

spec/stroma/settings/setting_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,10 @@
146146
expect(setting[:list][1][0]).to eq(2)
147147
end
148148
end
149+
150+
describe "protected interface" do
151+
it "does not expose data publicly" do
152+
expect { setting.data }.to raise_error(NoMethodError)
153+
end
154+
end
149155
end

0 commit comments

Comments
 (0)