diff options
Diffstat (limited to 'spec/unit/deprecation_spec.rb')
-rw-r--r-- | spec/unit/deprecation_spec.rb | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/spec/unit/deprecation_spec.rb b/spec/unit/deprecation_spec.rb index c5ab41fbab..f824cb7c76 100644 --- a/spec/unit/deprecation_spec.rb +++ b/spec/unit/deprecation_spec.rb @@ -54,32 +54,45 @@ describe Chef::Deprecation do it "defines all methods on #{class_object} that were available in 11.0" do old_methods.each do |old_method| - current_methods.should include(old_method.to_sym) + expect(current_methods).to include(old_method.to_sym) end end end - context 'deprecation warning messages' do - before(:each) do - @warning_output = [ ] - Chef::Log.stub(:warn) { |msg| @warning_output << msg } + context 'when Chef::Config[:treat_deprecation_warnings_as_errors] is off' do + before do + Chef::Config[:treat_deprecation_warnings_as_errors] = false end - it 'should be enabled for deprecated methods' do - TestClass.new.deprecated_method(10) - @warning_output.should_not be_empty + context 'deprecation warning messages' do + before(:each) do + @warning_output = [ ] + allow(Chef::Log).to receive(:warn) { |msg| @warning_output << msg } + end + + it 'should be enabled for deprecated methods' do + TestClass.new.deprecated_method(10) + expect(@warning_output).not_to be_empty + end + + it 'should contain stack trace' do + TestClass.new.deprecated_method(10) + expect(@warning_output.join("").include?(".rb")).to be_truthy + end end - it 'should contain stack trace' do - TestClass.new.deprecated_method(10) - @warning_output.join("").include?(".rb").should be_true + it 'deprecated methods should still be called' do + test_instance = TestClass.new + test_instance.deprecated_method(10) + expect(test_instance.get_value).to eq(10) end end - it 'deprecated methods should still be called' do + it 'should raise when deprecation warnings are treated as errors' do + # rspec should set this + expect(Chef::Config[:treat_deprecation_warnings_as_errors]).to be true test_instance = TestClass.new - test_instance.deprecated_method(10) - test_instance.get_value.should == 10 + expect { test_instance.deprecated_method(10) }.to raise_error(Chef::Exceptions::DeprecatedFeatureError) end end |