22
33RSpec . describe Deprecate do
44 let ( :output ) { StringIO . new }
5-
5+
66 before do
77 Deprecate . reset_warnings!
88 Deprecate . configure do |config |
99 config [ :output_stream ] = output
1010 config [ :warn_once ] = false
1111 end
1212 end
13-
13+
1414 after do
1515 Deprecate . configure do |config |
1616 config [ :output_stream ] = $stderr
2525 def old_method
2626 "old result"
2727 end
28-
28+
2929 def new_method
3030 "new result"
3131 end
32-
32+
3333 deprecate :old_method , :new_method
3434 end
3535 end
@@ -52,7 +52,7 @@ def new_method
5252 def legacy_method
5353 "legacy result"
5454 end
55-
55+
5656 deprecate :legacy_method
5757 end
5858 end
@@ -76,7 +76,7 @@ def legacy_method
7676 def old_method ( arg1 , arg2 )
7777 "#{ arg1 } -#{ arg2 } "
7878 end
79-
79+
8080 deprecate :old_method , :new_method
8181 end
8282 end
@@ -145,7 +145,7 @@ def call_private
145145 def old_method
146146 "result"
147147 end
148-
148+
149149 deprecate :old_method
150150 end
151151 end
@@ -154,7 +154,7 @@ def old_method
154154 obj = test_class . new
155155 obj . old_method
156156 obj . old_method
157-
157+
158158 warnings = output . string . scan ( /DEPRECATION WARNING/ )
159159 expect ( warnings . length ) . to eq ( 1 )
160160 end
@@ -173,7 +173,7 @@ def old_method
173173 def old_method
174174 "result"
175175 end
176-
176+
177177 deprecate :old_method , :new_method
178178 end
179179 end
@@ -190,22 +190,22 @@ def old_method
190190 it 'clears the warned methods hash' do
191191 # Just test that the hash gets cleared
192192 Deprecate . configure { |config | config [ :warn_once ] = true }
193-
193+
194194 # Add a warning to the hash
195195 test_class = Class . new do
196196 def old_method
197197 "result"
198198 end
199199 deprecate :old_method
200200 end
201-
201+
202202 obj = test_class . new
203- obj . old_method # This should add to warned_methods hash
204-
203+ obj . old_method # This should add to warned_methods hash
204+
205205 expect ( Deprecate . warned_methods ) . not_to be_empty
206-
206+
207207 Deprecate . reset_warnings!
208208 expect ( Deprecate . warned_methods ) . to be_empty
209209 end
210210 end
211- end
211+ end
0 commit comments