@@ -1277,9 +1277,17 @@ def genres
1277
1277
%w[ pop rock ]
1278
1278
end
1279
1279
end
1280
- ActiveSupport ::Deprecation . should_receive ( :warn )
1280
+ deprecation_instance = instance_double ( ActiveSupport ::Deprecation )
1281
+ allow ( ActiveSupport ::Deprecation ) . to receive ( :new ) . and_return ( deprecation_instance )
1282
+ allow ( deprecation_instance ) . to receive ( :warn )
1283
+
1281
1284
genres = klass . new . humanized_genres
1282
1285
genres . collect ( &:humanized ) . should == [ 'Pop music' , 'Rock music' ]
1286
+
1287
+ expect ( deprecation_instance ) . to have_received ( :warn ) . with (
1288
+ "humanized_<value>s is deprecated, use humanized_assignable_<value>s instead" ,
1289
+ instance_of ( Array )
1290
+ )
1283
1291
end
1284
1292
1285
1293
it "should define a method #humanized on assignable string values, which return up the value's' translation" do
@@ -1288,8 +1296,16 @@ def genres
1288
1296
%w[ pop rock ]
1289
1297
end
1290
1298
end
1291
- ActiveSupport ::Deprecation . should_receive ( :warn ) . at_least ( :once )
1299
+ deprecation_instance = instance_double ( ActiveSupport ::Deprecation )
1300
+ allow ( ActiveSupport ::Deprecation ) . to receive ( :new ) . and_return ( deprecation_instance )
1301
+ allow ( deprecation_instance ) . to receive ( :warn )
1302
+
1292
1303
klass . new . assignable_genres . collect ( &:humanized ) . should == [ 'Pop music' , 'Rock music' ]
1304
+
1305
+ expect ( deprecation_instance ) . to have_received ( :warn ) . with (
1306
+ "assignable_<value>.humanized is deprecated, use humanized_assignable_<value>s.humanized instead" ,
1307
+ instance_of ( Array )
1308
+ ) . at_least ( :once )
1293
1309
end
1294
1310
1295
1311
it 'should not define a method #humanized on values that are not strings' do
0 commit comments