Skip to content

Commit 9f80c7f

Browse files
author
Richard Degenne
committed
Add freeze behavior tests
1 parent da38709 commit 9f80c7f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spec/recursive_open_struct/open_struct_behavior_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,25 @@
108108
it { expect(subject.methods.map(&:to_sym)).to_not include :asdf= }
109109
end # describe #methods
110110
end # describe handling of arbitrary attributes
111+
112+
describe "handling of freezing" do
113+
let(:hash) { { :asdf => 'John Smith' } }
114+
115+
before do
116+
ros.freeze
117+
end
118+
119+
it "can read existing keys", pending: 'Awaiting fix' do
120+
expect(ros.asdf).to eq 'John Smith'
121+
end
122+
123+
it "cannot write new keys" do
124+
expect { ros.new_key = 'new_value' }.to raise_error FrozenError
125+
end
126+
127+
it "cannot write existing keys" do
128+
expect { ros.asdf = 'new_value' }.to raise_error FrozenError
129+
end
130+
end
111131
end # describe behavior it inherits from OpenStruct
112132
end

0 commit comments

Comments
 (0)