3333 end
3434 end
3535 end
36+ describe '#delete_for_plugin' do
37+ before ( :each ) { registry . for_plugin ( plugin_id ) . set ( :foo , 'bar' ) }
38+ it 'deletes the registry' do
39+ expect ( registry . exists? ( plugin_id ) ) . to be true
40+ registry . delete_for_plugin ( plugin_id )
41+ expect ( registry . exists? ( plugin_id ) ) . to be false
42+ end
43+ it 'deletes the data inside the registry' do
44+ plugin_registry = registry . for_plugin ( plugin_id )
45+ registry . delete_for_plugin ( plugin_id )
46+ expect ( plugin_registry . set? ( :foo ) ) . to be false
47+ end
48+ end
49+
3650 end
3751
3852 describe 'instance' do
4963 end
5064 end
5165 context 'when the key is set' do
52- before ( :each ) { instance . set ( :foo , 'bananas' ) }
66+ let ( :val ) { 'bananas' }
67+ before ( :each ) { instance . set ( :foo , val ) }
5368
5469 it 'sets the new value' do
5570 instance . set ( :foo , 'bar' )
5671 expect ( instance . get ( :foo ) ) . to eq ( 'bar' )
5772 end
5873 it 'returns the previous associated value' do
59- expect ( instance . set ( :foo , 'bar' ) ) . to eq ( 'bananas' )
74+ expect ( instance . set ( :foo , 'bar' ) ) . to eq ( val )
6075 end
6176 context 'when the new value is nil' do
6277 it 'unsets the value' do
94109 end
95110 end
96111 end
112+
113+ describe '#delete' do
114+ context 'when the key is set' do
115+ let ( :val ) { 'bananas' }
116+ before ( :each ) { instance . set ( :foo , val ) }
117+ it 'returns the value' do
118+ expect ( instance . delete ( :foo ) ) . to be val
119+ end
120+ it 'removes the key' do
121+ instance . delete ( :foo )
122+ expect ( instance . set? ( :foo ) ) . to be false
123+ end
124+ end
125+ context 'when the key is not set' do
126+ it 'returns nil' do
127+ expect ( instance . delete ( :foo ) ) . to be nil
128+ end
129+
130+ it 'should not be set' do
131+ instance . delete ( :foo )
132+ expect ( instance . set? ( :foo ) ) . to be false
133+ end
134+ end
135+ end
136+
137+ describe '#clear' do
138+ context 'when the key is set' do
139+ before ( :each ) do
140+ instance . set ( :foo , 'bananas' )
141+ instance . set ( :bar , 'more bananas' )
142+ end
143+ it 'removes all keys' do
144+ instance . clear
145+ expect ( instance . set? ( :foo ) ) . to be false
146+ expect ( instance . set? ( :bar ) ) . to be false
147+ end
148+ end
149+ end
97150 end
98151end
0 commit comments