diff options
author | sersut <serdar@opscode.com> | 2013-05-16 08:55:42 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2013-05-16 08:55:42 -0700 |
commit | ad2a8d7ab69213d7f2a6b367be12fa506adcb9b3 (patch) | |
tree | 3d16690b43580dc625c35ee7138d719fb5f1825e /spec | |
parent | 75edb5fe7ea4e51b269bb6e11a0c6b4cd491ff9b (diff) | |
download | chef-ad2a8d7ab69213d7f2a6b367be12fa506adcb9b3.tar.gz |
Spec for deprecation.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/data/file-providers-method-snapshot-chef-11-4.json | 1 | ||||
-rw-r--r-- | spec/unit/deprecation_spec.rb | 86 |
2 files changed, 87 insertions, 0 deletions
diff --git a/spec/data/file-providers-method-snapshot-chef-11-4.json b/spec/data/file-providers-method-snapshot-chef-11-4.json new file mode 100644 index 0000000000..25de35d9c5 --- /dev/null +++ b/spec/data/file-providers-method-snapshot-chef-11-4.json @@ -0,0 +1 @@ +{"Chef::Provider::CookbookFile":["whyrun_supported?","load_current_resource","action_create","file_cache_location","resource_cookbook","backup_new_resource","content_stale?","diff_current_from_content","is_binary?","diff_current","setup_acl","define_resource_requirements","compare_content","set_content","update_new_file_state","set_all_access_controls","action_create_if_missing","action_delete","action_touch","backup","deploy_tempfile","shell_out","shell_out!","run_command_compatible_options","checksum","access_controls","enforce_ownership_and_permissions","new_resource","new_resource=","current_resource","current_resource=","run_context","run_context=","action","action=","whyrun_mode?","node","resource_collection","cookbook_name","cleanup_after_converge","action_nothing","events","run_action","process_resource_requirements","set_updated_status","requirements","method_missing","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","psych_to_yaml","to_yaml_properties","to_yaml","systemu","to_json","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","to_s","inspect","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Provider::Directory":["whyrun_supported?","load_current_resource","define_resource_requirements","action_create","action_delete","diff_current_from_content","is_binary?","diff_current","setup_acl","compare_content","set_content","update_new_file_state","set_all_access_controls","action_create_if_missing","action_touch","backup","deploy_tempfile","shell_out","shell_out!","run_command_compatible_options","checksum","access_controls","enforce_ownership_and_permissions","new_resource","new_resource=","current_resource","current_resource=","run_context","run_context=","action","action=","whyrun_mode?","node","resource_collection","cookbook_name","cleanup_after_converge","action_nothing","events","run_action","process_resource_requirements","set_updated_status","requirements","method_missing","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","psych_to_yaml","to_yaml_properties","to_yaml","systemu","to_json","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","to_s","inspect","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Provider::File":["diff_current_from_content","is_binary?","diff_current","whyrun_supported?","load_current_resource","setup_acl","define_resource_requirements","compare_content","set_content","update_new_file_state","action_create","set_all_access_controls","action_create_if_missing","action_delete","action_touch","backup","deploy_tempfile","shell_out","shell_out!","run_command_compatible_options","checksum","access_controls","enforce_ownership_and_permissions","new_resource","new_resource=","current_resource","current_resource=","run_context","run_context=","action","action=","whyrun_mode?","node","resource_collection","cookbook_name","cleanup_after_converge","action_nothing","events","run_action","process_resource_requirements","set_updated_status","requirements","method_missing","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","psych_to_yaml","to_yaml_properties","to_yaml","systemu","to_json","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","to_s","inspect","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Provider::RemoteDirectory":["action_create","action_create_if_missing","file_class","load_current_resource","define_resource_requirements","action_delete","diff_current_from_content","is_binary?","diff_current","setup_acl","compare_content","set_content","update_new_file_state","set_all_access_controls","action_touch","backup","deploy_tempfile","shell_out","shell_out!","run_command_compatible_options","checksum","access_controls","enforce_ownership_and_permissions","new_resource","new_resource=","current_resource","current_resource=","run_context","run_context=","action","action=","whyrun_mode?","node","resource_collection","cookbook_name","cleanup_after_converge","action_nothing","events","run_action","process_resource_requirements","set_updated_status","requirements","method_missing","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","psych_to_yaml","to_yaml_properties","to_yaml","systemu","to_json","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","to_s","inspect","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Provider::RemoteFile":["load_current_resource","action_create","current_resource_matches_target_checksum?","matches_current_checksum?","backup_new_resource","source_file","http_client_opts","diff_current_from_content","is_binary?","diff_current","whyrun_supported?","setup_acl","define_resource_requirements","compare_content","set_content","update_new_file_state","set_all_access_controls","action_create_if_missing","action_delete","action_touch","backup","deploy_tempfile","shell_out","shell_out!","run_command_compatible_options","checksum","access_controls","enforce_ownership_and_permissions","new_resource","new_resource=","current_resource","current_resource=","run_context","run_context=","action","action=","whyrun_mode?","node","resource_collection","cookbook_name","cleanup_after_converge","action_nothing","events","run_action","process_resource_requirements","set_updated_status","requirements","method_missing","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","psych_to_yaml","to_yaml_properties","to_yaml","systemu","to_json","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","to_s","inspect","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Provider::Template":["load_current_resource","define_resource_requirements","action_create","template_finder","template_location","resource_cookbook","rendered","content_matches?","render_template","diff_current_from_content","is_binary?","diff_current","whyrun_supported?","setup_acl","compare_content","set_content","update_new_file_state","set_all_access_controls","action_create_if_missing","action_delete","action_touch","backup","deploy_tempfile","shell_out","shell_out!","run_command_compatible_options","checksum","access_controls","enforce_ownership_and_permissions","new_resource","new_resource=","current_resource","current_resource=","run_context","run_context=","action","action=","whyrun_mode?","node","resource_collection","cookbook_name","cleanup_after_converge","action_nothing","events","run_action","process_resource_requirements","set_updated_status","requirements","method_missing","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","psych_to_yaml","to_yaml_properties","to_yaml","systemu","to_json","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","to_s","inspect","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Resource::File":["content","backup","checksum","path","diff","owner","user","group","mode","params","params=","provider","provider=","allowed_actions","allowed_actions=","run_context","run_context=","cookbook_name","cookbook_name=","recipe_name","recipe_name=","enclosing_provider","enclosing_provider=","source_line","source_line=","retries","retries=","retry_delay","retry_delay=","updated","resource_name","not_if_args","only_if_args","elapsed_time","state","identity","updated=","node","method_missing","load_prior_resource","supports","action","name","noop","ignore_failure","epic_fail","notifies","resolve_notification_references","notifies_immediately","notifies_delayed","immediate_notifications","delayed_notifications","resources","subscribes","is","to_s","to_text","inspect","as_json","to_json","to_hash","only_if","not_if","defined_at","cookbook_version","events","run_action","validate_action","provider_for_action","customize_exception","should_skip?","updated_by_last_action","updated_by_last_action?","updated?","after_created","deprecated_ivar","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","registry_key_exists?","registry_get_values","registry_has_subkeys?","registry_get_subkeys","registry_value_exists?","registry_data_exists?","value_for_platform","platform?","value_for_platform_family","platform_family?","validate","set_or_return","search","data_bag","data_bag_item","psych_to_yaml","to_yaml_properties","to_yaml","systemu","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Resource::RemoteDirectory":["source","files_backup","purge","files_group","files_mode","files_owner","overwrite","cookbook","recursive","path","owner","user","group","mode","params","params=","provider","provider=","allowed_actions","allowed_actions=","run_context","run_context=","cookbook_name","cookbook_name=","recipe_name","recipe_name=","enclosing_provider","enclosing_provider=","source_line","source_line=","retries","retries=","retry_delay","retry_delay=","updated","resource_name","not_if_args","only_if_args","elapsed_time","state","identity","updated=","node","method_missing","load_prior_resource","supports","action","name","noop","ignore_failure","epic_fail","notifies","resolve_notification_references","notifies_immediately","notifies_delayed","immediate_notifications","delayed_notifications","resources","subscribes","is","to_s","to_text","inspect","as_json","to_json","to_hash","only_if","not_if","defined_at","cookbook_version","events","run_action","validate_action","provider_for_action","customize_exception","should_skip?","updated_by_last_action","updated_by_last_action?","updated?","after_created","deprecated_ivar","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","registry_key_exists?","registry_get_values","registry_has_subkeys?","registry_get_subkeys","registry_value_exists?","registry_data_exists?","value_for_platform","platform?","value_for_platform_family","platform_family?","validate","set_or_return","search","data_bag","data_bag_item","psych_to_yaml","to_yaml_properties","to_yaml","systemu","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"],"Chef::Resource::RemoteFile":["source","checksum","after_created","content","backup","path","diff","owner","user","group","mode","params","params=","provider","provider=","allowed_actions","allowed_actions=","run_context","run_context=","cookbook_name","cookbook_name=","recipe_name","recipe_name=","enclosing_provider","enclosing_provider=","source_line","source_line=","retries","retries=","retry_delay","retry_delay=","updated","resource_name","not_if_args","only_if_args","elapsed_time","state","identity","updated=","node","method_missing","load_prior_resource","supports","action","name","noop","ignore_failure","epic_fail","notifies","resolve_notification_references","notifies_immediately","notifies_delayed","immediate_notifications","delayed_notifications","resources","subscribes","is","to_s","to_text","inspect","as_json","to_json","to_hash","only_if","not_if","defined_at","cookbook_version","events","run_action","validate_action","provider_for_action","customize_exception","should_skip?","updated_by_last_action","updated_by_last_action?","updated?","deprecated_ivar","convert_to_class_name","convert_to_snake_case","snake_case_basename","filename_to_qualified_string","registry_key_exists?","registry_get_values","registry_has_subkeys?","registry_get_subkeys","registry_value_exists?","registry_data_exists?","value_for_platform","platform?","value_for_platform_family","platform_family?","validate","set_or_return","search","data_bag","data_bag_item","psych_to_yaml","to_yaml_properties","to_yaml","systemu","pretty_print","pretty_print_cycle","pretty_print_instance_variables","pretty_print_inspect","nil?","===","=~","!~","eql?","hash","<=>","class","singleton_class","clone","dup","initialize_dup","initialize_clone","taint","tainted?","untaint","untrust","untrusted?","trust","freeze","frozen?","methods","singleton_methods","protected_methods","private_methods","public_methods","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","instance_of?","kind_of?","is_a?","tap","send","public_send","respond_to?","respond_to_missing?","extend","display","method","public_method","define_singleton_method","object_id","to_enum","enum_for","pretty_inspect","==","equal?","!","!=","instance_eval","instance_exec","__send__","__id__"]} diff --git a/spec/unit/deprecation_spec.rb b/spec/unit/deprecation_spec.rb new file mode 100644 index 0000000000..fcd47b8084 --- /dev/null +++ b/spec/unit/deprecation_spec.rb @@ -0,0 +1,86 @@ +# +# Author:: Adam Jacob (<adam@opscode.com>) +# Copyright:: Copyright (c) 2008 Opscode, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'spec_helper' +require 'chef/deprecation/warnings' + +describe Chef::Deprecation do + + it "method snapshot before file-refactor should match current methods" do + method_snapshot_file = File.join(CHEF_SPEC_DATA, "file-providers-method-snapshot-chef-11-4.json") + method_snapshot = JSON.parse(File.open(method_snapshot_file).read()) + + method_snapshot.each do |class_name, old_methods| + class_object = class_from_string(class_name) + current_methods = class_object.public_instance_methods + + old_methods.each do |old_method| + if !current_methods.include?(old_method.to_sym) + fail "Can not find method '#{old_method.to_sym}' for class '#{class_name}'" + end + end + end + end + + context 'deprecation warning messages' do + before(:each) do + @warning_output = [ ] + Chef::Log.stub!(:warn) { |msg| @warning_output << msg } + end + + it 'should be enabled for deprecated methods' do + TestClass.new.deprecated_method(10) + @warning_output.should_not be_empty + end + + it 'should contain stack trace' do + TestClass.new.deprecated_method(10) + @warning_output.join("").include?(".rb").should be_true + end + end + + it 'deprecated methods should still be called' do + test_instance = TestClass.new + test_instance.deprecated_method(10) + test_instance.get_value.should == 10 + end + + def class_from_string(str) + str.split('::').inject(Object) do |mod, class_name| + mod.const_get(class_name) + end + end + + module DeprecatedMethods + def deprecated_method(value) + @value = value + end + + def get_value + @value + end + end + + class TestClass + extend Chef::Deprecation::Warnings + include DeprecatedMethods + add_deprecation_warnings_for(DeprecatedMethods.instance_methods) + end + +end + |