summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorMax Martin <max@puppetlabs.com>2011-04-13 17:30:44 -0700
committerMax Martin <max@puppetlabs.com>2011-04-13 17:30:44 -0700
commit3dde838ac992571e13262ea29ba3a0eb8152e753 (patch)
tree90520cf62bfa2f1bb9c992bbfe1bc47ae10471f2 /spec/unit
parentfe45c2417af580597cd39adec96a30a05a7cd66a (diff)
parent3ab44c7ce01ab86a995deb66228f5be95239c92a (diff)
Merge branch 'next'
* next: (204 commits) Revert "(#6928) Removed --ignoreimport" Updated CHANGELOG for 2.6.8rc1 (#6928) Removed --ignoreimport (#6928) Remove --parseonly (#6928) Add a Parser face with Validate action (#6830) Fix sha1 to digest/sha1 require issue for Ruby 1.9 (#6830) Fix UTF-8 encoding issue for Ruby 1.9 (#6830) Fix string method sub call on a symbol for Ruby 1.9 (#2331) Remove darwinports pkg provider, replace with rewritten macports provider (#7059) handle inherited action binding scope maint: ensure we handle '-foo=' options correctly in faces. (#2150) Fix File const lookup when configuring routes Fixed #7082 - Added system support for groups maint: install erb templates under lib/ maint: clean up the spec test headers in bulk. (#7056) Use 'face' rather than 'faces' in the production code. maint: eliminate deprecated since 2008 code from Puppet. (#6117) Add POST support to indirector requests (#6962) Move option handling into #parse_options, not #preinit. maint: whitespace cleanup for puppet/util/command_line. ...
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/agent/locker_spec.rb5
-rwxr-xr-xspec/unit/agent_spec.rb4
-rwxr-xr-xspec/unit/application/agent_spec.rb5
-rwxr-xr-xspec/unit/application/apply_spec.rb50
-rwxr-xr-xspec/unit/application/cert_spec.rb16
-rwxr-xr-xspec/unit/application/certificate_spec.rb20
-rwxr-xr-xspec/unit/application/config_spec.rb9
-rwxr-xr-xspec/unit/application/configurer_spec.rb32
-rwxr-xr-xspec/unit/application/describe_spec.rb5
-rwxr-xr-xspec/unit/application/doc_spec.rb5
-rwxr-xr-xspec/unit/application/face_base_spec.rb187
-rwxr-xr-xspec/unit/application/faces_spec.rb14
-rwxr-xr-x[-rw-r--r--]spec/unit/application/filebucket_spec.rb5
-rwxr-xr-xspec/unit/application/indirection_base_spec.rb38
-rwxr-xr-xspec/unit/application/inspect_spec.rb13
-rwxr-xr-xspec/unit/application/kick_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/application/master_spec.rb47
-rwxr-xr-xspec/unit/application/queue_spec.rb5
-rwxr-xr-xspec/unit/application/resource_spec.rb5
-rwxr-xr-xspec/unit/application_spec.rb65
-rwxr-xr-xspec/unit/configurer/downloader_spec.rb5
-rwxr-xr-xspec/unit/configurer/fact_handler_spec.rb5
-rwxr-xr-xspec/unit/configurer/plugin_handler_spec.rb5
-rwxr-xr-xspec/unit/configurer_spec.rb4
-rwxr-xr-xspec/unit/daemon_spec.rb5
-rwxr-xr-xspec/unit/dsl/resource_api_spec.rb5
-rwxr-xr-xspec/unit/dsl/resource_type_api_spec.rb5
-rwxr-xr-xspec/unit/face/catalog_spec.rb4
-rwxr-xr-xspec/unit/face/certificate_request_spec.rb3
-rwxr-xr-xspec/unit/face/certificate_revocation_list_spec.rb3
-rwxr-xr-xspec/unit/face/certificate_spec.rb14
-rwxr-xr-xspec/unit/face/config_spec.rb23
-rwxr-xr-xspec/unit/face/configurer_spec.rb25
-rwxr-xr-xspec/unit/face/facts_spec.rb20
-rwxr-xr-xspec/unit/face/file_spec.rb3
-rwxr-xr-xspec/unit/face/help_spec.rb112
-rwxr-xr-xspec/unit/face/indirector_spec.rb59
-rwxr-xr-xspec/unit/face/key_spec.rb3
-rwxr-xr-xspec/unit/face/node_spec.rb8
-rwxr-xr-xspec/unit/face/report_spec.rb3
-rwxr-xr-xspec/unit/face/resource_spec.rb3
-rwxr-xr-xspec/unit/face/resource_type_spec.rb3
-rwxr-xr-xspec/unit/face_spec.rb1
-rwxr-xr-xspec/unit/file_bucket/dipper_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/file_bucket/file_spec.rb5
-rwxr-xr-xspec/unit/file_collection/lookup_spec.rb5
-rwxr-xr-xspec/unit/file_collection_spec.rb5
-rwxr-xr-xspec/unit/file_serving/base_spec.rb5
-rwxr-xr-xspec/unit/file_serving/configuration/parser_spec.rb5
-rwxr-xr-xspec/unit/file_serving/configuration_spec.rb5
-rwxr-xr-xspec/unit/file_serving/content_spec.rb5
-rwxr-xr-xspec/unit/file_serving/fileset_spec.rb5
-rwxr-xr-xspec/unit/file_serving/indirection_hooks_spec.rb4
-rwxr-xr-xspec/unit/file_serving/metadata_spec.rb5
-rwxr-xr-xspec/unit/file_serving/mount/file_spec.rb5
-rwxr-xr-xspec/unit/file_serving/mount/modules_spec.rb5
-rwxr-xr-xspec/unit/file_serving/mount/plugins_spec.rb5
-rwxr-xr-xspec/unit/file_serving/mount_spec.rb5
-rwxr-xr-xspec/unit/file_serving/terminus_helper_spec.rb4
-rwxr-xr-xspec/unit/indirector/active_record_spec.rb5
-rwxr-xr-xspec/unit/indirector/catalog/active_record_spec.rb5
-rwxr-xr-xspec/unit/indirector/catalog/compiler_spec.rb4
-rwxr-xr-xspec/unit/indirector/catalog/queue_spec.rb5
-rwxr-xr-xspec/unit/indirector/catalog/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/catalog/yaml_spec.rb5
-rwxr-xr-xspec/unit/indirector/certificate/ca_spec.rb4
-rwxr-xr-xspec/unit/indirector/certificate/file_spec.rb4
-rwxr-xr-xspec/unit/indirector/certificate/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/certificate_request/ca_spec.rb49
-rwxr-xr-xspec/unit/indirector/certificate_request/file_spec.rb4
-rwxr-xr-xspec/unit/indirector/certificate_request/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/certificate_revocation_list/ca_spec.rb4
-rwxr-xr-xspec/unit/indirector/certificate_revocation_list/file_spec.rb4
-rwxr-xr-xspec/unit/indirector/certificate_revocation_list/rest_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/certificate_status/file_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/certificate_status/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/code_spec.rb5
-rwxr-xr-xspec/unit/indirector/direct_file_server_spec.rb4
-rwxr-xr-xspec/unit/indirector/envelope_spec.rb5
-rwxr-xr-xspec/unit/indirector/exec_spec.rb5
-rwxr-xr-xspec/unit/indirector/facts/active_record_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/facts/couch_spec.rb137
-rwxr-xr-xspec/unit/indirector/facts/facter_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/facts/inventory_active_record_spec.rb11
-rwxr-xr-xspec/unit/indirector/facts/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/facts/yaml_spec.rb5
-rwxr-xr-xspec/unit/indirector/file_bucket_file/file_spec.rb5
-rwxr-xr-xspec/unit/indirector/file_bucket_file/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/file_content/file_server_spec.rb4
-rwxr-xr-xspec/unit/indirector/file_content/file_spec.rb4
-rwxr-xr-xspec/unit/indirector/file_content/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/file_metadata/file_server_spec.rb4
-rwxr-xr-xspec/unit/indirector/file_metadata/file_spec.rb4
-rwxr-xr-xspec/unit/indirector/file_metadata/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/file_server_spec.rb4
-rwxr-xr-xspec/unit/indirector/file_spec.rb5
-rwxr-xr-xspec/unit/indirector/indirection_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/inventory/yaml_spec.rb5
-rwxr-xr-xspec/unit/indirector/key/ca_spec.rb4
-rwxr-xr-xspec/unit/indirector/key/file_spec.rb4
-rwxr-xr-xspec/unit/indirector/ldap_spec.rb5
-rwxr-xr-xspec/unit/indirector/memory_spec.rb5
-rwxr-xr-xspec/unit/indirector/node/active_record_spec.rb5
-rwxr-xr-xspec/unit/indirector/node/exec_spec.rb5
-rwxr-xr-xspec/unit/indirector/node/ldap_spec.rb5
-rwxr-xr-xspec/unit/indirector/node/memory_spec.rb5
-rwxr-xr-xspec/unit/indirector/node/plain_spec.rb5
-rwxr-xr-xspec/unit/indirector/node/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/node/yaml_spec.rb5
-rwxr-xr-xspec/unit/indirector/plain_spec.rb5
-rwxr-xr-xspec/unit/indirector/queue_spec.rb5
-rwxr-xr-xspec/unit/indirector/report/processor_spec.rb4
-rwxr-xr-xspec/unit/indirector/report/rest_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/report/yaml_spec.rb5
-rwxr-xr-xspec/unit/indirector/request_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/resource/ral_spec.rb5
-rwxr-xr-xspec/unit/indirector/resource/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/resource_type/parser_spec.rb5
-rwxr-xr-xspec/unit/indirector/resource_type/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/rest_spec.rb38
-rwxr-xr-x[-rw-r--r--]spec/unit/indirector/run/local_spec.rb5
-rwxr-xr-xspec/unit/indirector/run/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/ssl_file_spec.rb4
-rwxr-xr-xspec/unit/indirector/status/rest_spec.rb5
-rwxr-xr-xspec/unit/indirector/terminus_spec.rb5
-rwxr-xr-xspec/unit/indirector/yaml_spec.rb5
-rwxr-xr-xspec/unit/indirector_spec.rb64
-rwxr-xr-xspec/unit/interface/action_builder_spec.rb69
-rwxr-xr-xspec/unit/interface/action_manager_spec.rb232
-rwxr-xr-xspec/unit/interface/action_spec.rb172
-rwxr-xr-xspec/unit/interface/face_collection_spec.rb170
-rwxr-xr-xspec/unit/interface/option_builder_spec.rb29
-rwxr-xr-xspec/unit/interface/option_spec.rb75
-rwxr-xr-xspec/unit/interface_spec.rb207
-rwxr-xr-xspec/unit/module_spec.rb5
-rwxr-xr-xspec/unit/network/authconfig_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/network/authstore_spec.rb5
-rwxr-xr-xspec/unit/network/client_spec.rb4
-rwxr-xr-xspec/unit/network/format_handler_spec.rb5
-rwxr-xr-xspec/unit/network/format_spec.rb5
-rwxr-xr-xspec/unit/network/formats_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/network/handler/fileserver_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/network/http/api/v1_spec.rb31
-rwxr-xr-xspec/unit/network/http/compression_spec.rb5
-rwxr-xr-xspec/unit/network/http/handler_spec.rb5
-rwxr-xr-xspec/unit/network/http/mongrel/rest_spec.rb5
-rwxr-xr-xspec/unit/network/http/mongrel_spec.rb4
-rwxr-xr-xspec/unit/network/http/rack/rest_spec.rb5
-rwxr-xr-xspec/unit/network/http/rack/xmlrpc_spec.rb5
-rwxr-xr-xspec/unit/network/http/rack_spec.rb5
-rwxr-xr-xspec/unit/network/http/webrick/rest_spec.rb5
-rwxr-xr-xspec/unit/network/http/webrick_spec.rb4
-rwxr-xr-xspec/unit/network/http_pool_spec.rb4
-rwxr-xr-xspec/unit/network/http_spec.rb4
-rwxr-xr-xspec/unit/network/rest_authconfig_spec.rb5
-rwxr-xr-xspec/unit/network/rights_spec.rb5
-rwxr-xr-xspec/unit/network/server_spec.rb4
-rwxr-xr-xspec/unit/network/xmlrpc/client_spec.rb4
-rwxr-xr-xspec/unit/node/environment_spec.rb5
-rwxr-xr-xspec/unit/node/facts_spec.rb5
-rwxr-xr-xspec/unit/node_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/other/selinux_spec.rb5
-rwxr-xr-xspec/unit/other/transbucket_spec.rb5
-rwxr-xr-xspec/unit/other/transobject_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parameter/path_spec.rb4
-rwxr-xr-xspec/unit/parameter/value_collection_spec.rb5
-rwxr-xr-xspec/unit/parameter/value_spec.rb5
-rwxr-xr-xspec/unit/parameter_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/arithmetic_operator_spec.rb15
-rwxr-xr-xspec/unit/parser/ast/astarray_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast/asthash_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/boolean_operator_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/casestatement_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/collection_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/collexpr_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/comparison_operator_spec.rb9
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast/definition_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast/function_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast/hostclass_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/ifstatement_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast/in_operator_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/leaf_spec.rb42
-rwxr-xr-xspec/unit/parser/ast/match_operator_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/minus_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast/node_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/nop_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/not_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast/relationship_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/resource_defaults_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/resource_override_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/resource_reference_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/resource_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/selector_spec.rb5
-rwxr-xr-xspec/unit/parser/ast/vardef_spec.rb24
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/ast_spec.rb5
-rwxr-xr-xspec/unit/parser/collector_spec.rb5
-rwxr-xr-xspec/unit/parser/compiler_spec.rb9
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/files_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/create_resources_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/defined_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/extlookup_spec.rb15
-rwxr-xr-xspec/unit/parser/functions/fqdn_rand_spec.rb25
-rwxr-xr-xspec/unit/parser/functions/generate_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/include_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/inline_template_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/realize_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/regsubst_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/require_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/shellquote_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/split_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/sprintf_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/tag_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/template_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/versioncmp_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/functions_spec.rb5
-rwxr-xr-xspec/unit/parser/lexer_spec.rb5
-rwxr-xr-xspec/unit/parser/parser_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/relationship_spec.rb5
-rwxr-xr-xspec/unit/parser/resource_spec.rb5
-rwxr-xr-xspec/unit/parser/scope_spec.rb196
-rwxr-xr-xspec/unit/parser/templatewrapper_spec.rb45
-rwxr-xr-x[-rw-r--r--]spec/unit/parser/type_loader_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/property/ensure_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/property/keyvalue_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/property/list_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/property/ordered_list_spec.rb5
-rwxr-xr-xspec/unit/property_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/augeas/augeas_spec.rb5
-rwxr-xr-xspec/unit/provider/confine/exists_spec.rb5
-rwxr-xr-xspec/unit/provider/confine/false_spec.rb5
-rwxr-xr-xspec/unit/provider/confine/feature_spec.rb5
-rwxr-xr-xspec/unit/provider/confine/true_spec.rb5
-rwxr-xr-xspec/unit/provider/confine/variable_spec.rb5
-rwxr-xr-xspec/unit/provider/confine_collection_spec.rb5
-rwxr-xr-xspec/unit/provider/confine_spec.rb5
-rwxr-xr-xspec/unit/provider/confiner_spec.rb5
-rwxr-xr-xspec/unit/provider/exec/posix_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/exec/shell_spec.rb4
-rwxr-xr-xspec/unit/provider/group/groupadd_spec.rb17
-rwxr-xr-xspec/unit/provider/group/ldap_spec.rb4
-rwxr-xr-xspec/unit/provider/host/parsed_spec.rb5
-rwxr-xr-xspec/unit/provider/interface/cisco_spec.rb64
-rwxr-xr-xspec/unit/provider/ldap_spec.rb4
-rwxr-xr-xspec/unit/provider/macauthorization_spec.rb4
-rwxr-xr-xspec/unit/provider/mcx/mcxcontent_spec.rb23
-rwxr-xr-xspec/unit/provider/mount/parsed_spec.rb4
-rwxr-xr-xspec/unit/provider/mount_spec.rb5
-rwxr-xr-xspec/unit/provider/naginator_spec.rb5
-rwxr-xr-xspec/unit/provider/nameservice/directoryservice_spec.rb5
-rwxr-xr-xspec/unit/provider/network_device_spec.rb148
-rwxr-xr-xspec/unit/provider/package/aix_spec.rb5
-rwxr-xr-xspec/unit/provider/package/apt_spec.rb5
-rwxr-xr-xspec/unit/provider/package/dpkg_spec.rb5
-rwxr-xr-xspec/unit/provider/package/freebsd_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/package/gem_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/package/hpux_spec.rb5
-rwxr-xr-xspec/unit/provider/package/macports_spec.rb122
-rwxr-xr-xspec/unit/provider/package/nim_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/package/pip_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/package/pkg_spec.rb5
-rwxr-xr-xspec/unit/provider/package/pkgdmg_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/package/yum_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/package/zypper_spec.rb5
-rwxr-xr-xspec/unit/provider/parsedfile_spec.rb5
-rwxr-xr-xspec/unit/provider/selboolean_spec.rb5
-rwxr-xr-xspec/unit/provider/selmodule_spec.rb4
-rwxr-xr-xspec/unit/provider/service/daemontools_spec.rb4
-rwxr-xr-xspec/unit/provider/service/debian_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/service/freebsd_spec.rb5
-rwxr-xr-xspec/unit/provider/service/init_spec.rb4
-rwxr-xr-xspec/unit/provider/service/launchd_spec.rb4
-rwxr-xr-xspec/unit/provider/service/redhat_spec.rb4
-rwxr-xr-xspec/unit/provider/service/runit_spec.rb4
-rwxr-xr-xspec/unit/provider/service/smf_spec.rb4
-rwxr-xr-xspec/unit/provider/service/src_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/service/upstart.rb5
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed_spec.rb5
-rwxr-xr-xspec/unit/provider/sshkey/parsed_spec.rb5
-rwxr-xr-xspec/unit/provider/user/hpux_spec.rb5
-rwxr-xr-xspec/unit/provider/user/ldap_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/provider/user/user_role_add_spec.rb5
-rwxr-xr-xspec/unit/provider/user/useradd_spec.rb5
-rwxr-xr-xspec/unit/provider/vlan/cisco_spec.rb62
-rwxr-xr-xspec/unit/provider/zfs/solaris_spec.rb5
-rwxr-xr-xspec/unit/provider/zone/solaris_spec.rb5
-rwxr-xr-xspec/unit/provider/zpool/solaris_spec.rb5
-rwxr-xr-xspec/unit/provider_spec.rb5
-rw-r--r--spec/unit/puppet/provider/README.markdown4
-rw-r--r--spec/unit/puppet/type/README.markdown4
-rwxr-xr-xspec/unit/puppet_spec.rb4
-rwxr-xr-xspec/unit/rails/host_spec.rb5
-rwxr-xr-xspec/unit/rails/param_value_spec.rb5
-rwxr-xr-xspec/unit/rails/resource_spec.rb5
-rwxr-xr-xspec/unit/rails_spec.rb5
-rwxr-xr-xspec/unit/relationship_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/reports/http_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/reports/rrdgraph_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/reports/store_spec.rb5
-rwxr-xr-xspec/unit/reports/tagmail_spec.rb5
-rwxr-xr-xspec/unit/reports_spec.rb5
-rwxr-xr-xspec/unit/resource/catalog_spec.rb5
-rwxr-xr-xspec/unit/resource/status_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/resource/type_collection_helper_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/resource/type_collection_spec.rb10
-rwxr-xr-xspec/unit/resource/type_spec.rb41
-rwxr-xr-xspec/unit/resource_spec.rb5
-rwxr-xr-xspec/unit/run_spec.rb5
-rwxr-xr-xspec/unit/simple_graph_spec.rb4
-rwxr-xr-xspec/unit/ssl/base_spec.rb7
-rwxr-xr-xspec/unit/ssl/certificate_authority/interface_spec.rb5
-rwxr-xr-xspec/unit/ssl/certificate_authority_spec.rb5
-rwxr-xr-xspec/unit/ssl/certificate_factory_spec.rb5
-rwxr-xr-xspec/unit/ssl/certificate_request_spec.rb5
-rwxr-xr-xspec/unit/ssl/certificate_revocation_list_spec.rb5
-rwxr-xr-xspec/unit/ssl/certificate_spec.rb5
-rwxr-xr-xspec/unit/ssl/host_spec.rb5
-rwxr-xr-xspec/unit/ssl/inventory_spec.rb5
-rwxr-xr-xspec/unit/ssl/key_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/sslcertificates/ca_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/status_spec.rb5
-rwxr-xr-xspec/unit/transaction/event_manager_spec.rb5
-rwxr-xr-xspec/unit/transaction/event_spec.rb5
-rwxr-xr-xspec/unit/transaction/report_spec.rb24
-rwxr-xr-xspec/unit/transaction/resource_harness_spec.rb5
-rwxr-xr-xspec/unit/transaction_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/transportable_spec.rb0
-rwxr-xr-x[-rw-r--r--]spec/unit/type/augeas_spec.rb5
-rwxr-xr-xspec/unit/type/component_spec.rb5
-rwxr-xr-xspec/unit/type/computer_spec.rb5
-rwxr-xr-xspec/unit/type/cron_spec.rb15
-rwxr-xr-xspec/unit/type/exec_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/file/checksum_spec.rb5
-rwxr-xr-xspec/unit/type/file/content_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/file/ctime.rb5
-rwxr-xr-xspec/unit/type/file/ensure_spec.rb5
-rwxr-xr-xspec/unit/type/file/group_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/file/mtime.rb5
-rwxr-xr-xspec/unit/type/file/owner_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/file/selinux_spec.rb5
-rwxr-xr-xspec/unit/type/file/source_spec.rb6
-rwxr-xr-x[-rw-r--r--]spec/unit/type/file/type.rb5
-rwxr-xr-xspec/unit/type/file_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/filebucket_spec.rb5
-rwxr-xr-xspec/unit/type/group_spec.rb14
-rwxr-xr-xspec/unit/type/host_spec.rb5
-rwxr-xr-xspec/unit/type/interface_spec.rb93
-rwxr-xr-xspec/unit/type/macauthorization_spec.rb5
-rwxr-xr-xspec/unit/type/maillist_spec.rb5
-rwxr-xr-xspec/unit/type/mcx_spec.rb25
-rwxr-xr-xspec/unit/type/mount_spec.rb5
-rwxr-xr-xspec/unit/type/nagios_spec.rb5
-rwxr-xr-xspec/unit/type/noop_metaparam_spec.rb5
-rwxr-xr-xspec/unit/type/package_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/resources_spec.rb5
-rwxr-xr-xspec/unit/type/schedule_spec.rb5
-rwxr-xr-xspec/unit/type/selboolean_spec.rb5
-rwxr-xr-xspec/unit/type/selmodule_spec.rb5
-rwxr-xr-xspec/unit/type/service_spec.rb5
-rwxr-xr-xspec/unit/type/ssh_authorized_key_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/sshkey_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/type/stage_spec.rb5
-rwxr-xr-xspec/unit/type/tidy_spec.rb5
-rwxr-xr-xspec/unit/type/user_spec.rb5
-rwxr-xr-xspec/unit/type/vlan_spec.rb40
-rwxr-xr-x[-rw-r--r--]spec/unit/type/whit_spec.rb5
-rwxr-xr-xspec/unit/type/zfs_spec.rb5
-rwxr-xr-xspec/unit/type/zone_spec.rb5
-rwxr-xr-xspec/unit/type/zpool_spec.rb5
-rwxr-xr-xspec/unit/type_spec.rb5
-rwxr-xr-xspec/unit/util/autoload/file_cache_spec.rb5
-rwxr-xr-xspec/unit/util/autoload_spec.rb5
-rwxr-xr-xspec/unit/util/backups_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/util/cache_accumulator_spec.rb5
-rwxr-xr-xspec/unit/util/cacher_spec.rb5
-rwxr-xr-xspec/unit/util/checksums_spec.rb4
-rwxr-xr-xspec/unit/util/command_line_spec.rb17
-rwxr-xr-xspec/unit/util/constant_inflector_spec.rb4
-rwxr-xr-xspec/unit/util/errors_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/util/execution_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/util/execution_stub_spec.rb5
-rwxr-xr-xspec/unit/util/feature_spec.rb5
-rwxr-xr-xspec/unit/util/file_locking_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/util/filetype_spec.rb5
-rwxr-xr-xspec/unit/util/inline_docs_spec.rb5
-rwxr-xr-xspec/unit/util/ldap/connection_spec.rb4
-rwxr-xr-xspec/unit/util/ldap/generator_spec.rb4
-rwxr-xr-xspec/unit/util/ldap/manager_spec.rb4
-rwxr-xr-xspec/unit/util/loadedfile_spec.rb5
-rwxr-xr-xspec/unit/util/log/destinations_spec.rb5
-rwxr-xr-xspec/unit/util/log_spec.rb5
-rwxr-xr-xspec/unit/util/logging_spec.rb30
-rwxr-xr-xspec/unit/util/metric_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/util/monkey_patches_spec.rb28
-rwxr-xr-xspec/unit/util/nagios_maker_spec.rb4
-rwxr-xr-xspec/unit/util/network_device/cisco/device_spec.rb521
-rwxr-xr-xspec/unit/util/network_device/cisco/interface_spec.rb89
-rwxr-xr-xspec/unit/util/network_device/ipcalc_spec.rb63
-rwxr-xr-xspec/unit/util/network_device/transport/base_spec.rb42
-rwxr-xr-xspec/unit/util/network_device/transport/ssh_spec.rb211
-rwxr-xr-xspec/unit/util/network_device/transport/telnet_spec.rb76
-rwxr-xr-x[-rw-r--r--]spec/unit/util/package_spec.rb5
-rwxr-xr-xspec/unit/util/posix_spec.rb5
-rwxr-xr-xspec/unit/util/pson_spec.rb5
-rwxr-xr-xspec/unit/util/queue/stomp_spec.rb5
-rwxr-xr-xspec/unit/util/queue_spec.rb5
-rwxr-xr-xspec/unit/util/rdoc/parser_spec.rb5
-rwxr-xr-xspec/unit/util/rdoc_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/util/reference_serializer_spec.rb5
-rwxr-xr-xspec/unit/util/resource_template_spec.rb5
-rwxr-xr-x[-rw-r--r--]spec/unit/util/run_mode_spec.rb5
-rwxr-xr-xspec/unit/util/selinux_spec.rb5
-rwxr-xr-xspec/unit/util/settings/file_setting_spec.rb5
-rwxr-xr-xspec/unit/util/settings_spec.rb5
-rwxr-xr-xspec/unit/util/storage_spec.rb5
-rwxr-xr-xspec/unit/util/tagging_spec.rb4
-rwxr-xr-x[-rw-r--r--]spec/unit/util/user_attr_spec.rb5
-rwxr-xr-xspec/unit/util/warnings_spec.rb5
-rwxr-xr-xspec/unit/util/zaml_spec.rb5
418 files changed, 4322 insertions, 1562 deletions
diff --git a/spec/unit/agent/locker_spec.rb b/spec/unit/agent/locker_spec.rb
index e7c8929c7..341859e3b 100755
--- a/spec/unit/agent/locker_spec.rb
+++ b/spec/unit/agent/locker_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/agent'
require 'puppet/agent/locker'
diff --git a/spec/unit/agent_spec.rb b/spec/unit/agent_spec.rb
index a3a54bf7d..bfa44f61c 100755
--- a/spec/unit/agent_spec.rb
+++ b/spec/unit/agent_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-11-12.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
require 'puppet/agent'
class AgentTestClient
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index 804057868..03cf14429 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/agent'
require 'puppet/application/agent'
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index 0c6df2cf8..dca2a4156 100755
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/apply'
require 'puppet/file_bucket/dipper'
@@ -123,14 +122,6 @@ describe Puppet::Application::Apply do
describe "when executing" do
- it "should dispatch to parseonly if parseonly is set" do
- @apply.stubs(:options).returns({})
- Puppet.stubs(:[]).with(:parseonly).returns(true)
-
- @apply.expects(:parseonly)
- @apply.run_command
- end
-
it "should dispatch to 'apply' if it was called with 'apply'" do
@apply.options[:catalog] = "foo"
@@ -138,48 +129,13 @@ describe Puppet::Application::Apply do
@apply.run_command
end
- it "should dispatch to main if parseonly is not set" do
+ it "should dispatch to main otherwise" do
@apply.stubs(:options).returns({})
- Puppet.stubs(:[]).with(:parseonly).returns(false)
@apply.expects(:main)
@apply.run_command
end
- describe "the parseonly command" do
- before :each do
- @environment = Puppet::Node::Environment.new("env")
- Puppet.stubs(:[]).with(:environment).returns(@environment)
- Puppet.stubs(:[]).with(:manifest).returns("site.pp")
- Puppet.stubs(:err)
- @apply.stubs(:exit)
- @apply.options.stubs(:[]).with(:code).returns "some code"
- end
-
- it "should use the environment to parse the file" do
- @environment.stubs(:perform_initial_import)
- @apply.parseonly
- end
-
- it "should exit with exit code 0 if no error" do
- @apply.expects(:exit).with(0)
- @apply.parseonly
- end
-
- it "should exit with exit code 1 if error" do
- @environment.stubs(:perform_initial_import).raises(Puppet::ParseError)
- @apply.expects(:exit).with(1)
- @apply.parseonly
- end
-
- it "should exit with exit code 1 if error, even if --noop is set" do
- Puppet[:noop] = true
- @environment.stubs(:perform_initial_import).raises(Puppet::ParseError)
- @apply.expects(:exit).with(1)
- @apply.parseonly
- end
- end
-
describe "the main command" do
before :each do
Puppet.stubs(:[])
diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb
index 4315bb8d8..a1b5eb19a 100755
--- a/spec/unit/application/cert_spec.rb
+++ b/spec/unit/application/cert_spec.rb
@@ -1,7 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
-
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/cert'
describe Puppet::Application::Cert do
@@ -189,16 +187,6 @@ describe Puppet::Application::Cert do
@cert_app.ca = @ca
end
- it "should SystemExit after printing help message" do
- # Make the help method silent for testing; this is a bit nasty, but we
- # can't identify a cleaner method. Help welcome. --daniel 2011-02-22
- Puppet.features.stubs(:usage?).returns(false)
- @cert_app.stubs(:puts)
-
- @cert_app.command_line.stubs(:args).returns([])
- expect { @cert_app.parse_options }.should raise_error SystemExit
- end
-
%w{list revoke generate sign print verify fingerprint}.each do |cmd|
short = cmd[0,1]
[cmd, "--#{cmd}", "-#{short}"].each do |option|
diff --git a/spec/unit/application/certificate_spec.rb b/spec/unit/application/certificate_spec.rb
new file mode 100755
index 000000000..27d6ac81b
--- /dev/null
+++ b/spec/unit/application/certificate_spec.rb
@@ -0,0 +1,20 @@
+require 'puppet/application/certificate'
+
+describe Puppet::Application::Certificate do
+ it "should have a 'ca-location' option" do
+ # REVISIT: This is delegated from the face, and we will have a test there,
+ # so is this actually a valuable test? --daniel 2011-04-07
+ subject.command_line.stubs(:args).returns %w{list}
+ subject.preinit
+ subject.parse_options
+ subject.should respond_to(:handle_ca_location)
+ end
+
+ it "should accept the ca-location option" do
+ subject.command_line.stubs(:args).returns %w{--ca-location local list}
+ subject.preinit
+ subject.parse_options
+ subject.setup
+ subject.arguments.should == [{ :ca_location => "local" }]
+ end
+end
diff --git a/spec/unit/application/config_spec.rb b/spec/unit/application/config_spec.rb
new file mode 100755
index 000000000..dc2fb5717
--- /dev/null
+++ b/spec/unit/application/config_spec.rb
@@ -0,0 +1,9 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/application/config'
+
+describe Puppet::Application::Config do
+ it "should be a subclass of Puppet::Application::FaceBase" do
+ Puppet::Application::Config.superclass.should equal(Puppet::Application::FaceBase)
+ end
+end
diff --git a/spec/unit/application/configurer_spec.rb b/spec/unit/application/configurer_spec.rb
new file mode 100755
index 000000000..791a367ea
--- /dev/null
+++ b/spec/unit/application/configurer_spec.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/application/configurer'
+require 'puppet/indirector/catalog/rest'
+require 'puppet/indirector/report/rest'
+require 'tempfile'
+
+describe "Puppet::Application::Configurer" do
+ it "should retrieve and apply a catalog and submit a report" do
+ pending "REVISIT: 2.7 changes broke this, and we want the merge published"
+
+ dirname = Dir.mktmpdir("puppetdir")
+ Puppet[:vardir] = dirname
+ Puppet[:confdir] = dirname
+ Puppet[:certname] = "foo"
+ @catalog = Puppet::Resource::Catalog.new
+ @file = Puppet::Resource.new(:file, File.join(dirname, "tmp_dir_resource"), :parameters => {:ensure => :present})
+ @catalog.add_resource(@file)
+
+ @report = Puppet::Transaction::Report.new("apply")
+ Puppet::Transaction::Report.stubs(:new).returns(@report)
+
+ Puppet::Resource::Catalog::Rest.any_instance.stubs(:find).returns(@catalog)
+ @report.expects(:save)
+
+ Puppet::Util::Log.stubs(:newdestination)
+
+ Puppet::Application::Configurer.new.run
+
+ @report.status.should == "changed"
+ end
+end
diff --git a/spec/unit/application/describe_spec.rb b/spec/unit/application/describe_spec.rb
index 47b98a17b..e79ac21b7 100755
--- a/spec/unit/application/describe_spec.rb
+++ b/spec/unit/application/describe_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/describe'
diff --git a/spec/unit/application/doc_spec.rb b/spec/unit/application/doc_spec.rb
index f432184d3..66a833b9d 100755
--- a/spec/unit/application/doc_spec.rb
+++ b/spec/unit/application/doc_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/doc'
require 'puppet/util/reference'
diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb
new file mode 100755
index 000000000..939712ef8
--- /dev/null
+++ b/spec/unit/application/face_base_spec.rb
@@ -0,0 +1,187 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/application/face_base'
+require 'tmpdir'
+
+class Puppet::Application::FaceBase::Basetest < Puppet::Application::FaceBase
+end
+
+describe Puppet::Application::FaceBase do
+ before :all do
+ Puppet::Face.define(:basetest, '0.0.1') do
+ option("--[no-]boolean")
+ option("--mandatory MANDATORY")
+ option("--optional [OPTIONAL]")
+
+ action :foo do
+ option("--action")
+ when_invoked { |*args| args.length }
+ end
+ end
+ end
+
+ let :app do
+ app = Puppet::Application::FaceBase::Basetest.new
+ app.command_line.stubs(:subcommand_name).returns('subcommand')
+ Puppet::Util::Log.stubs(:newdestination)
+ app
+ end
+
+ describe "#find_global_settings_argument" do
+ it "should not match --ca to --ca-location" do
+ option = mock('ca option', :optparse_args => ["--ca"])
+ Puppet.settings.expects(:each).yields(:ca, option)
+
+ app.find_global_settings_argument("--ca-location").should be_nil
+ end
+ end
+
+ describe "#parse_options" do
+ before :each do
+ app.command_line.stubs(:args).returns %w{}
+ end
+
+ describe "parsing the command line" do
+ context "with just an action" do
+ before :all do
+ # We have to stub Signal.trap to avoid a crazy mess where we take
+ # over signal handling and make it impossible to cancel the test
+ # suite run.
+ #
+ # It would be nice to fix this elsewhere, but it is actually hard to
+ # capture this in rspec 2.5 and all. :( --daniel 2011-04-08
+ Signal.stubs(:trap)
+ app.command_line.stubs(:args).returns %w{foo}
+ app.preinit
+ app.parse_options
+ end
+
+ it "should set the face based on the type" do
+ app.face.name.should == :basetest
+ end
+
+ it "should set the format based on the face default" do
+ app.format.should == :pson
+ end
+
+ it "should find the action" do
+ app.action.should be
+ app.action.name.should == :foo
+ end
+ end
+
+ it "should fail if no action is given" do
+ expect { app.preinit; app.parse_options }.
+ to raise_error OptionParser::MissingArgument, /No action given/
+ end
+
+ it "should report a sensible error when options with = fail" do
+ app.command_line.stubs(:args).returns %w{--action=bar foo}
+ expect { app.preinit; app.parse_options }.
+ to raise_error OptionParser::InvalidOption, /invalid option: --action/
+ end
+
+ it "should fail if an action option is before the action" do
+ app.command_line.stubs(:args).returns %w{--action foo}
+ expect { app.preinit; app.parse_options }.
+ to raise_error OptionParser::InvalidOption, /invalid option: --action/
+ end
+
+ it "should fail if an unknown option is before the action" do
+ app.command_line.stubs(:args).returns %w{--bar foo}
+ expect { app.preinit; app.parse_options }.
+ to raise_error OptionParser::InvalidOption, /invalid option: --bar/
+ end
+
+ it "should fail if an unknown option is after the action" do
+ app.command_line.stubs(:args).returns %w{foo --bar}
+ expect { app.preinit; app.parse_options }.
+ to raise_error OptionParser::InvalidOption, /invalid option: --bar/
+ end
+
+ it "should accept --bar as an argument to a mandatory option after action" do
+ app.command_line.stubs(:args).returns %w{foo --mandatory --bar}
+ app.preinit
+ app.parse_options
+ app.action.name.should == :foo
+ app.options.should == { :mandatory => "--bar" }
+ end
+
+ it "should accept --bar as an argument to a mandatory option before action" do
+ app.command_line.stubs(:args).returns %w{--mandatory --bar foo}
+ app.preinit
+ app.parse_options
+ app.action.name.should == :foo
+ app.options.should == { :mandatory => "--bar" }
+ end
+
+ it "should not skip when --foo=bar is given" do
+ app.command_line.stubs(:args).returns %w{--mandatory=bar --bar foo}
+ expect { app.preinit; app.parse_options }.
+ to raise_error OptionParser::InvalidOption, /invalid option: --bar/
+ end
+
+ { "boolean options before" => %w{--trace foo},
+ "boolean options after" => %w{foo --trace}
+ }.each do |name, args|
+ it "should accept global boolean settings #{name} the action" do
+ app.command_line.stubs(:args).returns args
+ app.preinit
+ app.parse_options
+ Puppet[:trace].should be_true
+ end
+ end
+
+ { "before" => %w{--syslogfacility user1 foo},
+ " after" => %w{foo --syslogfacility user1}
+ }.each do |name, args|
+ it "should accept global settings with arguments #{name} the action" do
+ app.command_line.stubs(:args).returns args
+ app.preinit
+ app.parse_options
+ Puppet[:syslogfacility].should == "user1"
+ end
+ end
+ end
+ end
+
+ describe "#setup" do
+ it "should remove the action name from the arguments" do
+ app.command_line.stubs(:args).returns %w{--mandatory --bar foo}
+ app.preinit
+ app.parse_options
+ app.setup
+ app.arguments.should == [{ :mandatory => "--bar" }]
+ end
+
+ it "should pass positional arguments" do
+ app.command_line.stubs(:args).returns %w{--mandatory --bar foo bar baz quux}
+ app.preinit
+ app.parse_options
+ app.setup
+ app.arguments.should == ['bar', 'baz', 'quux', { :mandatory => "--bar" }]
+ end
+ end
+
+ describe "#main" do
+ before :each do
+ app.expects(:exit).with(0)
+
+ app.face = Puppet::Face[:basetest, '0.0.1']
+ app.action = app.face.get_action(:foo)
+ app.format = :pson
+ app.arguments = ["myname", "myarg"]
+ end
+
+ it "should send the specified verb and name to the face" do
+ app.face.expects(:foo).with(*app.arguments)
+ app.main
+ end
+
+ it "should use its render method to render any result" do
+ app.expects(:render).with(app.arguments.length + 1)
+ app.stubs(:puts) # meh. Don't print nil, thanks. --daniel 2011-04-12
+ app.main
+ end
+ end
+end
diff --git a/spec/unit/application/faces_spec.rb b/spec/unit/application/faces_spec.rb
new file mode 100755
index 000000000..cc159b6a5
--- /dev/null
+++ b/spec/unit/application/faces_spec.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/application/faces'
+
+describe Puppet::Application::Faces do
+ it "should be an application" do
+ Puppet::Application::Faces.superclass.should equal(Puppet::Application)
+ end
+
+ it "should always call 'list'" do
+ subject.expects(:list)
+ subject.main
+ end
+end
diff --git a/spec/unit/application/filebucket_spec.rb b/spec/unit/application/filebucket_spec.rb
index 013e358d8..8ba86be9e 100644..100755
--- a/spec/unit/application/filebucket_spec.rb
+++ b/spec/unit/application/filebucket_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/filebucket'
require 'puppet/file_bucket/dipper'
diff --git a/spec/unit/application/indirection_base_spec.rb b/spec/unit/application/indirection_base_spec.rb
new file mode 100755
index 000000000..63ab11eed
--- /dev/null
+++ b/spec/unit/application/indirection_base_spec.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/application/indirection_base'
+require 'puppet/face/indirector'
+
+########################################################################
+# Stub for testing; the names are critical, sadly. --daniel 2011-03-30
+class Puppet::Application::TestIndirection < Puppet::Application::IndirectionBase
+end
+
+face = Puppet::Face::Indirector.define(:testindirection, '0.0.1') do
+end
+# REVISIT: This horror is required because we don't allow anything to be
+# :current except for if it lives on, and is loaded from, disk. --daniel 2011-03-29
+face.instance_variable_set('@version', :current)
+Puppet::Face.register(face)
+########################################################################
+
+
+describe Puppet::Application::IndirectionBase do
+ subject { Puppet::Application::TestIndirection.new }
+
+ it "should accept a terminus command line option" do
+ # It would be nice not to have to stub this, but whatever... writing an
+ # entire indirection stack would cause us more grief. --daniel 2011-03-31
+ terminus = mock("test indirection terminus")
+ Puppet::Indirector::Indirection.expects(:instance).
+ with(:testindirection).twice.returns()
+
+ subject.command_line.
+ instance_variable_set('@args', %w{--terminus foo save})
+
+ # Not a very nice thing. :(
+ $stderr.stubs(:puts)
+
+ expect { subject.run }.should raise_error SystemExit
+ end
+end
diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb
index d334a87ee..fda61c6e4 100755
--- a/spec/unit/application/inspect_spec.rb
+++ b/spec/unit/application/inspect_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/inspect'
require 'puppet/resource/catalog'
@@ -246,9 +245,9 @@ describe Puppet::Application::Inspect do
@inspect.run_command
@report.status.should == "failed"
- @report.logs.select{|log| log.message =~ /Could not inspect/}.count.should == 1
- @report.resource_statuses.count.should == 1
- @report.resource_statuses['Stub_type[foo]'].events.count.should == 1
+ @report.logs.select{|log| log.message =~ /Could not inspect/}.size.should == 1
+ @report.resource_statuses.size.should == 1
+ @report.resource_statuses['Stub_type[foo]'].events.size.should == 1
event = @report.resource_statuses['Stub_type[foo]'].events.first
event.property.should == "content"
@@ -265,7 +264,7 @@ describe Puppet::Application::Inspect do
@inspect.run_command
- @report.resource_statuses.count.should == 2
+ @report.resource_statuses.size.should == 2
@report.resource_statuses.keys.should =~ ['Stub_type[foo]', 'Stub_type[bar]']
end
end
diff --git a/spec/unit/application/kick_spec.rb b/spec/unit/application/kick_spec.rb
index ce0e0c7d0..29e4caea4 100755
--- a/spec/unit/application/kick_spec.rb
+++ b/spec/unit/application/kick_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/kick'
diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb
index 14478a61a..ea5d3f518 100644..100755
--- a/spec/unit/application/master_spec.rb
+++ b/spec/unit/application/master_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/master'
require 'puppet/daemon'
@@ -35,10 +34,6 @@ describe Puppet::Application::Master do
@master.should respond_to(:main)
end
- it "should declare a parseonly command" do
- @master.should respond_to(:parseonly)
- end
-
it "should declare a compile command" do
@master.should respond_to(:compile)
end
@@ -233,55 +228,19 @@ describe Puppet::Application::Master do
@master.preinit
end
- it "should dispatch to parseonly if parseonly is set" do
- Puppet.stubs(:[]).with(:parseonly).returns(true)
- @master.options[:node] = nil
-
- @master.expects(:parseonly)
- @master.run_command
- end
-
it "should dispatch to compile if called with --compile" do
@master.options[:node] = "foo"
@master.expects(:compile)
@master.run_command
end
- it "should dispatch to main if parseonly is not set" do
- Puppet.stubs(:[]).with(:parseonly).returns(false)
+ it "should dispatch to main otherwise" do
@master.options[:node] = nil
@master.expects(:main)
@master.run_command
end
-
- describe "the parseonly command" do
- before :each do
- @environment = Puppet::Node::Environment.new("env")
- Puppet.stubs(:[]).with(:environment).returns(@environment)
- Puppet.stubs(:[]).with(:manifest).returns("site.pp")
- Puppet.stubs(:err)
- @master.stubs(:exit)
- end
-
- it "should use a Puppet Resource Type Collection to parse the file" do
- @environment.expects(:perform_initial_import)
- @master.parseonly
- end
-
- it "should exit with exit code 0 if no error" do
- @master.expects(:exit).with(0)
- @master.parseonly
- end
-
- it "should exit with exit code 1 if error" do
- @environment.stubs(:perform_initial_import).raises(Puppet::ParseError)
- @master.expects(:exit).with(1)
- @master.parseonly
- end
- end
-
describe "the compile command" do
before do
Puppet.stubs(:[]).with(:environment)
diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb
index bb485ac3c..87713ca97 100755
--- a/spec/unit/application/queue_spec.rb
+++ b/spec/unit/application/queue_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/queue'
require 'puppet/indirector/catalog/queue'
diff --git a/spec/unit/application/resource_spec.rb b/spec/unit/application/resource_spec.rb
index 3e3f8296b..673bd65d7 100755
--- a/spec/unit/application/resource_spec.rb
+++ b/spec/unit/application/resource_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application/resource'
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index befc4f510..f46959092 100755
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/application'
require 'puppet'
@@ -12,6 +11,7 @@ describe Puppet::Application do
@app = Class.new(Puppet::Application).new
@appclass = @app.class
+ @app.stubs(:name).returns("test_app")
# avoid actually trying to parse any settings
Puppet.settings.stubs(:parse)
end
@@ -356,16 +356,6 @@ describe Puppet::Application do
end
end
-
- it "should exit if OptionParser raises an error" do
- $stderr.stubs(:puts)
- OptionParser.any_instance.stubs(:parse!).raises(OptionParser::ParseError.new("blah blah"))
-
- @app.expects(:exit)
-
- lambda { @app.parse_options }.should_not raise_error
- end
-
end
describe "when calling default setup" do
@@ -396,6 +386,55 @@ describe Puppet::Application do
end
+ describe "when configuring routes" do
+ include PuppetSpec::Files
+
+ before :each do
+ Puppet::Node.indirection.reset_terminus_class
+ end
+
+ after :each do
+ Puppet::Node.indirection.reset_terminus_class
+ end
+
+ it "should use the routes specified for only the active application" do
+ Puppet[:route_file] = tmpfile('routes')
+ File.open(Puppet[:route_file], 'w') do |f|
+ f.print <<-ROUTES
+ test_app:
+ node:
+ terminus: exec
+ other_app:
+ node:
+ terminus: plain
+ catalog:
+ terminus: invalid
+ ROUTES
+ end
+
+ @app.configure_indirector_routes
+
+ Puppet::Node.indirection.terminus_class.should == 'exec'
+ end
+
+ it "should not fail if the route file doesn't exist" do
+ Puppet[:route_file] = "/dev/null/non-existent"
+
+ expect { @app.configure_indirector_routes }.should_not raise_error
+ end
+
+ it "should raise an error if the routes file is invalid" do
+ Puppet[:route_file] = tmpfile('routes')
+ File.open(Puppet[:route_file], 'w') do |f|
+ f.print <<-ROUTES
+ invalid : : yaml
+ ROUTES
+ end
+
+ expect { @app.configure_indirector_routes }.should raise_error
+ end
+ end
+
describe "when running" do
before :each do
diff --git a/spec/unit/configurer/downloader_spec.rb b/spec/unit/configurer/downloader_spec.rb
index 266a96b03..17b285d53 100755
--- a/spec/unit/configurer/downloader_spec.rb
+++ b/spec/unit/configurer/downloader_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/configurer/downloader'
diff --git a/spec/unit/configurer/fact_handler_spec.rb b/spec/unit/configurer/fact_handler_spec.rb
index 71645225f..70d9b17c0 100755
--- a/spec/unit/configurer/fact_handler_spec.rb
+++ b/spec/unit/configurer/fact_handler_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/configurer'
require 'puppet/configurer/fact_handler'
diff --git a/spec/unit/configurer/plugin_handler_spec.rb b/spec/unit/configurer/plugin_handler_spec.rb
index 04a479665..7d99960df 100755
--- a/spec/unit/configurer/plugin_handler_spec.rb
+++ b/spec/unit/configurer/plugin_handler_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/configurer'
require 'puppet/configurer/plugin_handler'
diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb
index d21d86ecf..7b76c3221 100755
--- a/spec/unit/configurer_spec.rb
+++ b/spec/unit/configurer_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-11-12.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
require 'puppet/configurer'
describe Puppet::Configurer do
diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb
index 4de76b728..ed8dec2a3 100755
--- a/spec/unit/daemon_spec.rb
+++ b/spec/unit/daemon_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/daemon'
def without_warnings
diff --git a/spec/unit/dsl/resource_api_spec.rb b/spec/unit/dsl/resource_api_spec.rb
index 13aa6a437..559a43333 100755
--- a/spec/unit/dsl/resource_api_spec.rb
+++ b/spec/unit/dsl/resource_api_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/dsl/resource_api'
diff --git a/spec/unit/dsl/resource_type_api_spec.rb b/spec/unit/dsl/resource_type_api_spec.rb
index 795ce2868..ea81f7da4 100755
--- a/spec/unit/dsl/resource_type_api_spec.rb
+++ b/spec/unit/dsl/resource_type_api_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/dsl/resource_type_api'
diff --git a/spec/unit/face/catalog_spec.rb b/spec/unit/face/catalog_spec.rb
new file mode 100755
index 000000000..28c2aa9be
--- /dev/null
+++ b/spec/unit/face/catalog_spec.rb
@@ -0,0 +1,4 @@
+require 'puppet/face'
+describe Puppet::Face[:catalog, '0.0.1'] do
+ it "should actually have some testing..."
+end
diff --git a/spec/unit/face/certificate_request_spec.rb b/spec/unit/face/certificate_request_spec.rb
new file mode 100755
index 000000000..a83a92df8
--- /dev/null
+++ b/spec/unit/face/certificate_request_spec.rb
@@ -0,0 +1,3 @@
+describe Puppet::Face[:certificate_request, '0.0.1'] do
+ it "should actually have some tests..."
+end
diff --git a/spec/unit/face/certificate_revocation_list_spec.rb b/spec/unit/face/certificate_revocation_list_spec.rb
new file mode 100755
index 000000000..22c0fa2bf
--- /dev/null
+++ b/spec/unit/face/certificate_revocation_list_spec.rb
@@ -0,0 +1,3 @@
+describe Puppet::Face[:certificate_revocation_list, '0.0.1'] do
+ it "should actually have some tests..."
+end
diff --git a/spec/unit/face/certificate_spec.rb b/spec/unit/face/certificate_spec.rb
new file mode 100755
index 000000000..dbcc888ad
--- /dev/null
+++ b/spec/unit/face/certificate_spec.rb
@@ -0,0 +1,14 @@
+require 'puppet/ssl/host'
+
+describe Puppet::Face[:certificate, '0.0.1'] do
+ it "should have a ca-location option" do
+ subject.should be_option :ca_location
+ end
+
+ it "should set the ca location when invoked" do
+ pending "#6983: This is broken in the actual face..."
+ Puppet::SSL::Host.expects(:ca_location=).with(:foo)
+ Puppet::SSL::Host.indirection.expects(:save)
+ subject.sign :ca_location => :foo
+ end
+end
diff --git a/spec/unit/face/config_spec.rb b/spec/unit/face/config_spec.rb
new file mode 100755
index 000000000..6004d700f
--- /dev/null
+++ b/spec/unit/face/config_spec.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe Puppet::Face[:config, '0.0.1'] do
+ it "should use Settings#print_config_options when asked to print" do
+ Puppet.settings.stubs(:puts)
+ Puppet.settings.expects(:print_config_options)
+ subject.print
+ end
+
+ it "should set 'configprint' to all desired values and call print_config_options when a specific value is provided" do
+ Puppet.settings.stubs(:puts)
+ Puppet.settings.expects(:print_config_options)
+ subject.print("libdir", "ssldir")
+ Puppet.settings[:configprint].should == "libdir,ssldir"
+ end
+
+ it "should always return nil" do
+ Puppet.settings.stubs(:puts)
+ Puppet.settings.expects(:print_config_options)
+ subject.print("libdir").should be_nil
+ end
+end
diff --git a/spec/unit/face/configurer_spec.rb b/spec/unit/face/configurer_spec.rb
new file mode 100755
index 000000000..56b45031f
--- /dev/null
+++ b/spec/unit/face/configurer_spec.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/indirector/catalog/rest'
+require 'tempfile'
+
+describe Puppet::Face[:configurer, '0.0.1'] do
+ describe "#synchronize" do
+ it "should retrieve and apply a catalog and return a report" do
+ pending "REVISIT: 2.7 changes broke this, and we want the merge published"
+
+ dirname = Dir.mktmpdir("puppetdir")
+ Puppet[:vardir] = dirname
+ Puppet[:confdir] = dirname
+ @catalog = Puppet::Resource::Catalog.new
+ @file = Puppet::Resource.new(:file, File.join(dirname, "tmp_dir_resource"), :parameters => {:ensure => :present})
+ @catalog.add_resource(@file)
+ Puppet::Resource::Catalog::Rest.any_instance.stubs(:find).returns(@catalog)
+
+ report = subject.synchronize("foo")
+
+ report.kind.should == "apply"
+ report.status.should == "changed"
+ end
+ end
+end
diff --git a/spec/unit/face/facts_spec.rb b/spec/unit/face/facts_spec.rb
new file mode 100755
index 000000000..e6411f836
--- /dev/null
+++ b/spec/unit/face/facts_spec.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe Puppet::Face[:facts, '0.0.1'] do
+ it "should define an 'upload' fact" do
+ subject.should be_action(:upload)
+ end
+
+ it "should set its default format to :yaml" do
+ subject.default_format.should == :yaml
+ end
+
+ describe "when uploading" do
+ it "should set the terminus_class to :facter"
+
+ it "should set the cach_eclass to :rest"
+
+ it "should find the current certname"
+ end
+end
diff --git a/spec/unit/face/file_spec.rb b/spec/unit/face/file_spec.rb
new file mode 100755
index 000000000..97e8bcc08
--- /dev/null
+++ b/spec/unit/face/file_spec.rb
@@ -0,0 +1,3 @@
+describe Puppet::Face[:file, '0.0.1'] do
+ it "should actually have some tests..."
+end
diff --git a/spec/unit/face/help_spec.rb b/spec/unit/face/help_spec.rb
new file mode 100755
index 000000000..e67f29e07
--- /dev/null
+++ b/spec/unit/face/help_spec.rb
@@ -0,0 +1,112 @@
+require 'spec_helper'
+require 'puppet/face/help'
+
+describe Puppet::Face[:help, '0.0.1'] do
+ it "should have a help action" do
+ subject.should be_action :help
+ end
+
+ it "should have a default action of help" do
+ pending "REVISIT: we don't support default actions yet"
+ end
+
+ it "should accept a call with no arguments" do
+ expect { subject.help() }.should_not raise_error
+ end
+
+ it "should accept a face name" do
+ expect { subject.help(:help) }.should_not raise_error
+ end
+
+ it "should accept a face and action name" do
+ expect { subject.help(:help, :help) }.should_not raise_error
+ end
+
+ it "should fail if more than a face and action are given" do
+ expect { subject.help(:help, :help, :for_the_love_of_god) }.
+ should raise_error ArgumentError
+ end
+
+ it "should treat :current and 'current' identically" do
+ subject.help(:help, :version => :current).should ==
+ subject.help(:help, :version => 'current')
+ end
+
+ it "should complain when the request version of a face is missing" do
+ expect { subject.help(:huzzah, :bar, :version => '17.0.0') }.
+ should raise_error Puppet::Error
+ end
+
+ it "should find a face by version" do
+ face = Puppet::Face[:huzzah, :current]
+ subject.help(:huzzah, :version => face.version).
+ should == subject.help(:huzzah, :version => :current)
+ end
+
+ context "when listing subcommands" do
+ subject { Puppet::Face[:help, :current].help }
+
+ # Check a precondition for the next block; if this fails you have
+ # something odd in your set of face, and we skip testing things that
+ # matter. --daniel 2011-04-10
+ it "should have at least one face with a summary" do
+ Puppet::Face.faces.should be_any do |name|
+ Puppet::Face[name, :current].summary
+ end
+ end
+
+ Puppet::Face.faces.each do |name|
+ face = Puppet::Face[name, :current]
+ summary = face.summary
+
+ it { should =~ %r{ #{name} } }
+ it { should =~ %r{ #{name} +#{summary}} } if summary
+ end
+
+ Puppet::Face[:help, :current].legacy_applications.each do |appname|
+ it { should =~ %r{ #{appname} } }
+
+ summary = Puppet::Face[:help, :current].horribly_extract_summary_from(appname)
+ summary and it { should =~ %r{ #{summary}\b} }
+ end
+ end
+
+ context "#legacy_applications" do
+ subject { Puppet::Face[:help, :current].legacy_applications }
+
+ # If we don't, these tests are ... less than useful, because they assume
+ # it. When this breaks you should consider ditching the entire feature
+ # and tests, but if not work out how to fake one. --daniel 2011-04-11
+ it { should have_at_least(1).item }
+
+ # Meh. This is nasty, but we can't control the other list; the specific
+ # bug that caused these to be listed is annoyingly subtle and has a nasty
+ # fix, so better to have a "fail if you do something daft" trigger in
+ # place here, I think. --daniel 2011-04-11
+ %w{face_base indirection_base}.each do |name|
+ it { should_not include name }
+ end
+ end
+
+ context "help for legacy applications" do
+ subject { Puppet::Face[:help, :current] }
+ let :appname do subject.legacy_applications.first end
+
+ # This test is purposely generic, so that as we eliminate legacy commands
+ # we don't get into a loop where we either test a face-based replacement
+ # and fail to notice breakage, or where we have to constantly rewrite this
+ # test and all. --daniel 2011-04-11
+ it "should return the legacy help when given the subcommand" do
+ help = subject.help(appname)
+ help.should =~ /puppet-#{appname}/
+ %w{SYNOPSIS USAGE DESCRIPTION OPTIONS COPYRIGHT}.each do |heading|
+ help.should =~ /^#{heading}$/
+ end
+ end
+
+ it "should fail when asked for an action on a legacy command" do
+ expect { subject.help(appname, :whatever) }.
+ to raise_error ArgumentError, /Legacy subcommands don't take actions/
+ end
+ end
+end
diff --git a/spec/unit/face/indirector_spec.rb b/spec/unit/face/indirector_spec.rb
new file mode 100755
index 000000000..bb06fcfe2
--- /dev/null
+++ b/spec/unit/face/indirector_spec.rb
@@ -0,0 +1,59 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/face/indirector'
+
+describe Puppet::Face::Indirector do
+ subject do
+ instance = Puppet::Face::Indirector.new(:test, '0.0.1')
+ indirection = stub('indirection',
+ :name => :stub_indirection,
+ :reset_terminus_class => nil)
+ instance.stubs(:indirection).returns indirection
+ instance
+ end
+
+ it "should be able to return a list of indirections" do
+ Puppet::Face::Indirector.indirections.should be_include("catalog")
+ end
+
+ it "should be able to return a list of terminuses for a given indirection" do
+ Puppet::Face::Indirector.terminus_classes(:catalog).should be_include("compiler")
+ end
+
+ describe "as an instance" do
+ it "should be able to determine its indirection" do
+ # Loading actions here an get, um, complicated
+ Puppet::Face.stubs(:load_actions)
+ Puppet::Face::Indirector.new(:catalog, '0.0.1').indirection.should equal(Puppet::Resource::Catalog.indirection)
+ end
+ end
+
+ [:find, :search, :save, :destroy].each do |method|
+ it "should define a '#{method}' action" do
+ Puppet::Face::Indirector.should be_action(method)
+ end
+
+ it "should call the indirection method with options when the '#{method}' action is invoked" do
+ subject.indirection.expects(method).with(:test, "myargs", {})
+ subject.send(method, :test, "myargs")
+ end
+ it "should forward passed options" do
+ subject.indirection.expects(method).with(:test, "action", {'one'=>'1'})
+ subject.send(method, :test, 'action', {'one'=>'1'})
+ end
+ end
+
+ it "should be able to override its indirection name" do
+ subject.set_indirection_name :foo
+ subject.indirection_name.should == :foo
+ end
+
+ it "should be able to set its terminus class" do
+ subject.indirection.expects(:terminus_class=).with(:myterm)
+ subject.set_terminus(:myterm)
+ end
+
+ it "should define a class-level 'info' action" do
+ Puppet::Face::Indirector.should be_action(:info)
+ end
+end
diff --git a/spec/unit/face/key_spec.rb b/spec/unit/face/key_spec.rb
new file mode 100755
index 000000000..10d664790
--- /dev/null
+++ b/spec/unit/face/key_spec.rb
@@ -0,0 +1,3 @@
+describe Puppet::Face[:key, '0.0.1'] do
+ it "should actually have some tests..."
+end
diff --git a/spec/unit/face/node_spec.rb b/spec/unit/face/node_spec.rb
new file mode 100755
index 000000000..90d258db9
--- /dev/null
+++ b/spec/unit/face/node_spec.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe Puppet::Face[:node, '0.0.1'] do
+ it "should set its default format to :yaml" do
+ subject.default_format.should == :yaml
+ end
+end
diff --git a/spec/unit/face/report_spec.rb b/spec/unit/face/report_spec.rb
new file mode 100755
index 000000000..b1b28167e
--- /dev/null
+++ b/spec/unit/face/report_spec.rb
@@ -0,0 +1,3 @@
+describe Puppet::Face[:report, '0.0.1'] do
+ it "should actually have some tests..."
+end
diff --git a/spec/unit/face/resource_spec.rb b/spec/unit/face/resource_spec.rb
new file mode 100755
index 000000000..084e2a6a9
--- /dev/null
+++ b/spec/unit/face/resource_spec.rb
@@ -0,0 +1,3 @@
+describe Puppet::Face[:resource, '0.0.1'] do
+ it "should actually have some tests..."
+end
diff --git a/spec/unit/face/resource_type_spec.rb b/spec/unit/face/resource_type_spec.rb
new file mode 100755
index 000000000..2adaedca1
--- /dev/null
+++ b/spec/unit/face/resource_type_spec.rb
@@ -0,0 +1,3 @@
+describe Puppet::Face[:resource_type, '0.0.1'] do
+ it "should actually have some tests..."
+end
diff --git a/spec/unit/face_spec.rb b/spec/unit/face_spec.rb
new file mode 100755
index 000000000..b6c49d917
--- /dev/null
+++ b/spec/unit/face_spec.rb
@@ -0,0 +1 @@
+# You should look at interface_spec.rb
diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb
index 4dabb722b..910b2808d 100755
--- a/spec/unit/file_bucket/dipper_spec.rb
+++ b/spec/unit/file_bucket/dipper_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'pathname'
diff --git a/spec/unit/file_bucket/file_spec.rb b/spec/unit/file_bucket/file_spec.rb
index d79345736..c4444ae77 100644..100755
--- a/spec/unit/file_bucket/file_spec.rb
+++ b/spec/unit/file_bucket/file_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require ::File.dirname(__FILE__) + '/../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_bucket/file'
require 'digest/md5'
diff --git a/spec/unit/file_collection/lookup_spec.rb b/spec/unit/file_collection/lookup_spec.rb
index 138949a96..2b0f8bfab 100755
--- a/spec/unit/file_collection/lookup_spec.rb
+++ b/spec/unit/file_collection/lookup_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_collection/lookup'
class LookupTester
diff --git a/spec/unit/file_collection_spec.rb b/spec/unit/file_collection_spec.rb
index 09888f425..518763629 100755
--- a/spec/unit/file_collection_spec.rb
+++ b/spec/unit/file_collection_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_collection'
diff --git a/spec/unit/file_serving/base_spec.rb b/spec/unit/file_serving/base_spec.rb
index 3449c8d0e..17d59460e 100755
--- a/spec/unit/file_serving/base_spec.rb
+++ b/spec/unit/file_serving/base_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/base'
diff --git a/spec/unit/file_serving/configuration/parser_spec.rb b/spec/unit/file_serving/configuration/parser_spec.rb
index 46cdc1c45..3d6b3e234 100755
--- a/spec/unit/file_serving/configuration/parser_spec.rb
+++ b/spec/unit/file_serving/configuration/parser_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/configuration/parser'
diff --git a/spec/unit/file_serving/configuration_spec.rb b/spec/unit/file_serving/configuration_spec.rb
index 3c6113165..6ee1a4f38 100755
--- a/spec/unit/file_serving/configuration_spec.rb
+++ b/spec/unit/file_serving/configuration_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/configuration'
diff --git a/spec/unit/file_serving/content_spec.rb b/spec/unit/file_serving/content_spec.rb
index 576cbde1f..2637ba6ce 100755
--- a/spec/unit/file_serving/content_spec.rb
+++ b/spec/unit/file_serving/content_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/content'
diff --git a/spec/unit/file_serving/fileset_spec.rb b/spec/unit/file_serving/fileset_spec.rb
index 3b12c953e..a369ad39c 100755
--- a/spec/unit/file_serving/fileset_spec.rb
+++ b/spec/unit/file_serving/fileset_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/fileset'
diff --git a/spec/unit/file_serving/indirection_hooks_spec.rb b/spec/unit/file_serving/indirection_hooks_spec.rb
index 1c7f55da8..4890505ab 100755
--- a/spec/unit/file_serving/indirection_hooks_spec.rb
+++ b/spec/unit/file_serving/indirection_hooks_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-18.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/file_serving/indirection_hooks'
diff --git a/spec/unit/file_serving/metadata_spec.rb b/spec/unit/file_serving/metadata_spec.rb
index 34794cca9..39f2a9548 100755
--- a/spec/unit/file_serving/metadata_spec.rb
+++ b/spec/unit/file_serving/metadata_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/metadata'
diff --git a/spec/unit/file_serving/mount/file_spec.rb b/spec/unit/file_serving/mount/file_spec.rb
index 792ce951c..70c804abd 100755
--- a/spec/unit/file_serving/mount/file_spec.rb
+++ b/spec/unit/file_serving/mount/file_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/mount/file'
module FileServingMountTesting
diff --git a/spec/unit/file_serving/mount/modules_spec.rb b/spec/unit/file_serving/mount/modules_spec.rb
index 1213f4fa5..2d582daa2 100755
--- a/spec/unit/file_serving/mount/modules_spec.rb
+++ b/spec/unit/file_serving/mount/modules_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/mount/modules'
describe Puppet::FileServing::Mount::Modules do
diff --git a/spec/unit/file_serving/mount/plugins_spec.rb b/spec/unit/file_serving/mount/plugins_spec.rb
index 6aa9ae927..b6bed72a0 100755
--- a/spec/unit/file_serving/mount/plugins_spec.rb
+++ b/spec/unit/file_serving/mount/plugins_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/mount/plugins'
describe Puppet::FileServing::Mount::Plugins do
diff --git a/spec/unit/file_serving/mount_spec.rb b/spec/unit/file_serving/mount_spec.rb
index 2bfe643f6..5d8e64f82 100755
--- a/spec/unit/file_serving/mount_spec.rb
+++ b/spec/unit/file_serving/mount_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_serving/mount'
describe Puppet::FileServing::Mount do
diff --git a/spec/unit/file_serving/terminus_helper_spec.rb b/spec/unit/file_serving/terminus_helper_spec.rb
index 36cf0daf3..7efe3fb98 100755
--- a/spec/unit/file_serving/terminus_helper_spec.rb
+++ b/spec/unit/file_serving/terminus_helper_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-22.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/file_serving/terminus_helper'
diff --git a/spec/unit/indirector/active_record_spec.rb b/spec/unit/indirector/active_record_spec.rb
index 4fab17da2..2baef33fe 100755
--- a/spec/unit/indirector/active_record_spec.rb
+++ b/spec/unit/indirector/active_record_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/rails'
require 'puppet/indirector/active_record'
diff --git a/spec/unit/indirector/catalog/active_record_spec.rb b/spec/unit/indirector/catalog/active_record_spec.rb
index da1d77582..35d01179b 100755
--- a/spec/unit/indirector/catalog/active_record_spec.rb
+++ b/spec/unit/indirector/catalog/active_record_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "Puppet::Resource::Catalog::ActiveRecord", :if => Puppet.features.rails? do
diff --git a/spec/unit/indirector/catalog/compiler_spec.rb b/spec/unit/indirector/catalog/compiler_spec.rb
index a2ab0c6f4..cd84031e5 100755
--- a/spec/unit/indirector/catalog/compiler_spec.rb
+++ b/spec/unit/indirector/catalog/compiler_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-9-23.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/catalog/compiler'
require 'puppet/rails'
diff --git a/spec/unit/indirector/catalog/queue_spec.rb b/spec/unit/indirector/catalog/queue_spec.rb
index 866113631..d396ad897 100755
--- a/spec/unit/indirector/catalog/queue_spec.rb
+++ b/spec/unit/indirector/catalog/queue_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/catalog/queue'
diff --git a/spec/unit/indirector/catalog/rest_spec.rb b/spec/unit/indirector/catalog/rest_spec.rb
index c887504a2..3e674dde9 100755
--- a/spec/unit/indirector/catalog/rest_spec.rb
+++ b/spec/unit/indirector/catalog/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/catalog/rest'
diff --git a/spec/unit/indirector/catalog/yaml_spec.rb b/spec/unit/indirector/catalog/yaml_spec.rb
index 3bf5b4640..ddaa173c6 100755
--- a/spec/unit/indirector/catalog/yaml_spec.rb
+++ b/spec/unit/indirector/catalog/yaml_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/resource/catalog'
require 'puppet/indirector/catalog/yaml'
diff --git a/spec/unit/indirector/certificate/ca_spec.rb b/spec/unit/indirector/certificate/ca_spec.rb
index 77384ddb8..277d2209d 100755
--- a/spec/unit/indirector/certificate/ca_spec.rb
+++ b/spec/unit/indirector/certificate/ca_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/certificate/ca'
diff --git a/spec/unit/indirector/certificate/file_spec.rb b/spec/unit/indirector/certificate/file_spec.rb
index 45dd95cb5..f398e1115 100755
--- a/spec/unit/indirector/certificate/file_spec.rb
+++ b/spec/unit/indirector/certificate/file_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/certificate/file'
diff --git a/spec/unit/indirector/certificate/rest_spec.rb b/spec/unit/indirector/certificate/rest_spec.rb
index 8fd6bff9a..21e10e316 100755
--- a/spec/unit/indirector/certificate/rest_spec.rb
+++ b/spec/unit/indirector/certificate/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/certificate/rest'
diff --git a/spec/unit/indirector/certificate_request/ca_spec.rb b/spec/unit/indirector/certificate_request/ca_spec.rb
index 8c25e40f7..ebd64a2fb 100755
--- a/spec/unit/indirector/certificate_request/ca_spec.rb
+++ b/spec/unit/indirector/certificate_request/ca_spec.rb
@@ -1,13 +1,32 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
+require 'puppet/ssl/host'
+require 'puppet/sslcertificates'
+require 'puppet/sslcertificates/ca'
require 'puppet/indirector/certificate_request/ca'
describe Puppet::SSL::CertificateRequest::Ca do
+ include PuppetSpec::Files
+
+ before :each do
+ Puppet[:ssldir] = tmpdir('ssl')
+
+ Puppet::SSL::Host.ca_location = :local
+ Puppet[:localcacert] = Puppet[:cacert]
+ Puppet::SSLCertificates::CA.new.mkrootcert
+
+ @ca = Puppet::SSL::CertificateAuthority.new
+ end
+
+ after :all do
+ Puppet::SSL::Host.ca_location = :none
+ end
+
it "should have documentation" do
Puppet::SSL::CertificateRequest::Ca.doc.should be_instance_of(String)
end
@@ -16,4 +35,30 @@ describe Puppet::SSL::CertificateRequest::Ca do
Puppet.settings.expects(:value).with(:csrdir).returns "/request/dir"
Puppet::SSL::CertificateRequest::Ca.collection_directory.should == "/request/dir"
end
+
+ it "should overwrite the previous certificate request if allow_duplicate_certs is true" do
+ Puppet[:allow_duplicate_certs] = true
+ host = Puppet::SSL::Host.new("foo")
+ host.generate_certificate_request
+ @ca.sign(host.name)
+
+ Puppet::SSL::Host.indirection.find("foo").generate_certificate_request
+
+ Puppet::SSL::Certificate.indirection.find("foo").name.should == "foo"
+ Puppet::SSL::CertificateRequest.indirection.find("foo").name.should == "foo"
+ Puppet::SSL::Host.indirection.find("foo").state.should == "requested"
+ end
+
+ it "should reject a new certificate request if allow_duplicate_certs is false" do
+ Puppet[:allow_duplicate_certs] = false
+ host = Puppet::SSL::Host.new("bar")
+ host.generate_certificate_request
+ @ca.sign(host.name)
+
+ expect { Puppet::SSL::Host.indirection.find("bar").generate_certificate_request }.should raise_error(/ignoring certificate request/)
+
+ Puppet::SSL::Certificate.indirection.find("bar").name.should == "bar"
+ Puppet::SSL::CertificateRequest.indirection.find("bar").should be_nil
+ Puppet::SSL::Host.indirection.find("bar").state.should == "signed"
+ end
end
diff --git a/spec/unit/indirector/certificate_request/file_spec.rb b/spec/unit/indirector/certificate_request/file_spec.rb
index 465d55d3c..69dc5eb9c 100755
--- a/spec/unit/indirector/certificate_request/file_spec.rb
+++ b/spec/unit/indirector/certificate_request/file_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/certificate_request/file'
diff --git a/spec/unit/indirector/certificate_request/rest_spec.rb b/spec/unit/indirector/certificate_request/rest_spec.rb
index 9a8b87439..398b91b84 100755
--- a/spec/unit/indirector/certificate_request/rest_spec.rb
+++ b/spec/unit/indirector/certificate_request/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/certificate_request/rest'
diff --git a/spec/unit/indirector/certificate_revocation_list/ca_spec.rb b/spec/unit/indirector/certificate_revocation_list/ca_spec.rb
index d72a3bb10..d76373b97 100755
--- a/spec/unit/indirector/certificate_revocation_list/ca_spec.rb
+++ b/spec/unit/indirector/certificate_revocation_list/ca_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/certificate_revocation_list/ca'
diff --git a/spec/unit/indirector/certificate_revocation_list/file_spec.rb b/spec/unit/indirector/certificate_revocation_list/file_spec.rb
index 3284bee35..f4b8c36d3 100755
--- a/spec/unit/indirector/certificate_revocation_list/file_spec.rb
+++ b/spec/unit/indirector/certificate_revocation_list/file_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/certificate_revocation_list/file'
diff --git a/spec/unit/indirector/certificate_revocation_list/rest_spec.rb b/spec/unit/indirector/certificate_revocation_list/rest_spec.rb
index e47a0848c..238ba75ff 100755
--- a/spec/unit/indirector/certificate_revocation_list/rest_spec.rb
+++ b/spec/unit/indirector/certificate_revocation_list/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/certificate_revocation_list/rest'
diff --git a/spec/unit/indirector/certificate_status/file_spec.rb b/spec/unit/indirector/certificate_status/file_spec.rb
index 6cc0bb547..ae03aa9cb 100644..100755
--- a/spec/unit/indirector/certificate_status/file_spec.rb
+++ b/spec/unit/indirector/certificate_status/file_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/host'
require 'puppet/indirector/certificate_status'
require 'tempfile'
diff --git a/spec/unit/indirector/certificate_status/rest_spec.rb b/spec/unit/indirector/certificate_status/rest_spec.rb
index f44eac671..39fbb7024 100644..100755
--- a/spec/unit/indirector/certificate_status/rest_spec.rb
+++ b/spec/unit/indirector/certificate_status/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/host'
require 'puppet/indirector/certificate_status'
diff --git a/spec/unit/indirector/code_spec.rb b/spec/unit/indirector/code_spec.rb
index 1c9e4d2f1..29369bf5e 100755
--- a/spec/unit/indirector/code_spec.rb
+++ b/spec/unit/indirector/code_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/code'
describe Puppet::Indirector::Code do
diff --git a/spec/unit/indirector/direct_file_server_spec.rb b/spec/unit/indirector/direct_file_server_spec.rb
index 5d9af626f..abd7172b7 100755
--- a/spec/unit/indirector/direct_file_server_spec.rb
+++ b/spec/unit/indirector/direct_file_server_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-24.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/direct_file_server'
diff --git a/spec/unit/indirector/envelope_spec.rb b/spec/unit/indirector/envelope_spec.rb
index 2715a2671..e056b768c 100755
--- a/spec/unit/indirector/envelope_spec.rb
+++ b/spec/unit/indirector/envelope_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/envelope'
describe Puppet::Indirector::Envelope do
diff --git a/spec/unit/indirector/exec_spec.rb b/spec/unit/indirector/exec_spec.rb
index 5abb00ae9..1050ed4cc 100755
--- a/spec/unit/indirector/exec_spec.rb
+++ b/spec/unit/indirector/exec_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/exec'
diff --git a/spec/unit/indirector/facts/active_record_spec.rb b/spec/unit/indirector/facts/active_record_spec.rb
index 71e19e3ca..01a906716 100755
--- a/spec/unit/indirector/facts/active_record_spec.rb
+++ b/spec/unit/indirector/facts/active_record_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/rails'
require 'puppet/node/facts'
diff --git a/spec/unit/indirector/facts/couch_spec.rb b/spec/unit/indirector/facts/couch_spec.rb
index 1f86b56f2..d0862486c 100644..100755
--- a/spec/unit/indirector/facts/couch_spec.rb
+++ b/spec/unit/indirector/facts/couch_spec.rb
@@ -1,97 +1,102 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/node/facts'
+require 'puppet/indirector/facts/couch'
-describe "Puppet::Node::Facts::Couch", :if => Puppet.features.couchdb? do
- require 'puppet/indirector/facts/couch' if Puppet.features.couchdb?
-
- before do
- @mock_db = mock('couch db')
- mock_document = CouchRest::Document.new(:_id => fake_request.key, :facts => fake_request.values)
- mock_document.stubs(:database).returns(@mock_db)
- @mock_db.stubs(:get).with(fake_request.key).returns(mock_document)
- Puppet::Node::Facts::Couch.stubs(:db).returns(@mock_db)
+describe "Puppet::Node::Facts::Couch" do
+ describe "when couchdb is not available", :unless => Puppet.features.couchdb? do
+ it "should fail to initialize" do
+ lambda { Puppet::Node::Facts::Couch.new }.should raise_error
+ end
end
- subject { Puppet::Node::Facts::Couch }
-
- describe "#find" do
- describe "when the node document exists" do
- it "should find the request by key" do
- @mock_db.expects(:get).with(fake_request.key).returns({'_id' => fake_request.key, 'facts' => fake_request.instance.values})
- subject.new.find(fake_request).should == fake_request.instance
- end
+ describe "when couchdb is available", :if => Puppet.features.couchdb? do
+ before do
+ @mock_db = mock('couch db')
+ mock_document = CouchRest::Document.new(:_id => fake_request.key, :facts => fake_request.values)
+ mock_document.stubs(:database).returns(@mock_db)
+ @mock_db.stubs(:get).with(fake_request.key).returns(mock_document)
+ Puppet::Node::Facts::Couch.stubs(:db).returns(@mock_db)
end
- describe "when the node document does not exist" do
- before do
- @mock_db.expects(:get).
- with(fake_request.key).
- raises(RestClient::ResourceNotFound)
- end
+ subject { Puppet::Node::Facts::Couch }
- it "should return nil" do
- subject.new.find(fake_request).should be_nil
+ describe "#find" do
+ describe "when the node document exists" do
+ it "should find the request by key" do
+ @mock_db.expects(:get).with(fake_request.key).returns({'_id' => fake_request.key, 'facts' => fake_request.instance.values})
+ subject.new.find(fake_request).should == fake_request.instance
+ end
end
- it "should send Puppet a debug message" do
- Puppet.expects(:debug).with("No couchdb document with id: test.local")
- subject.new.find(fake_request).should be_nil
- end
+ describe "when the node document does not exist" do
+ before do
+ @mock_db.expects(:get).
+ with(fake_request.key).
+ raises(RestClient::ResourceNotFound)
+ end
- end
- end
+ it "should return nil" do
+ subject.new.find(fake_request).should be_nil
+ end
- describe "#save" do
- describe "with options" do
- subject do
- lambda { Puppet::Node::Facts::Couch.new.save(fake_request([1])) }
- end
+ it "should send Puppet a debug message" do
+ Puppet.expects(:debug).with("No couchdb document with id: test.local")
+ subject.new.find(fake_request).should be_nil
+ end
- it { should raise_error(ArgumentError, "PUT does not accept options") }
+ end
end
- it "should save the json to the CouchDB database" do
- @mock_db.expects(:save_doc).at_least_once.returns({'ok' => true })
- subject.new.save(fake_request)
- end
+ describe "#save" do
+ describe "with options" do
+ subject do
+ lambda { Puppet::Node::Facts::Couch.new.save(fake_request([1])) }
+ end
- describe "when the document exists" do
- before do
- @doc = CouchRest::Document.new(:_id => fake_request.key, :facts => fake_request.instance.values)
- @mock_db.expects(:get).with(fake_request.key).returns(@doc)
+ it { should raise_error(ArgumentError, "PUT does not accept options") }
end
- it "saves the document" do
- @doc.expects(:save)
+ it "should save the json to the CouchDB database" do
+ @mock_db.expects(:save_doc).at_least_once.returns({'ok' => true })
subject.new.save(fake_request)
end
- end
+ describe "when the document exists" do
+ before do
+ @doc = CouchRest::Document.new(:_id => fake_request.key, :facts => fake_request.instance.values)
+ @mock_db.expects(:get).with(fake_request.key).returns(@doc)
+ end
+
+ it "saves the document" do
+ @doc.expects(:save)
+ subject.new.save(fake_request)
+ end
- describe "when the document does not exist" do
- before do
- @mock_db.expects(:get).
- with(fake_request.key).
- raises(RestClient::ResourceNotFound)
end
- it "saves the document" do
- @mock_db.expects(:save_doc)
- subject.new.save(fake_request)
+ describe "when the document does not exist" do
+ before do
+ @mock_db.expects(:get).
+ with(fake_request.key).
+ raises(RestClient::ResourceNotFound)
+ end
+
+ it "saves the document" do
+ @mock_db.expects(:save_doc)
+ subject.new.save(fake_request)
+ end
+
end
end
+ def fake_request(options={})
+ facts = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml', 'test.local.yaml'))
+ Struct.new(:instance, :key, :options).new(facts, facts.name, options)
+ end
+ private :fake_request
end
-
- def fake_request(options={})
- facts = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml', 'test.local.yaml'))
- Struct.new(:instance, :key, :options).new(facts, facts.name, options)
- end
- private :fake_request
-
end
diff --git a/spec/unit/indirector/facts/facter_spec.rb b/spec/unit/indirector/facts/facter_spec.rb
index 3129f5ebf..9f5a0249b 100755
--- a/spec/unit/indirector/facts/facter_spec.rb
+++ b/spec/unit/indirector/facts/facter_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-9-23.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/facts/facter'
diff --git a/spec/unit/indirector/facts/inventory_active_record_spec.rb b/spec/unit/indirector/facts/inventory_active_record_spec.rb
index 43b9fa397..edd03d8e4 100644..100755
--- a/spec/unit/indirector/facts/inventory_active_record_spec.rb
+++ b/spec/unit/indirector/facts/inventory_active_record_spec.rb
@@ -1,7 +1,9 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'sqlite3' rescue nil
+#!/usr/bin/env rspec
+require 'spec_helper'
+begin
+ require 'sqlite3'
+rescue LoadError
+end
require 'tempfile'
require 'puppet/rails'
@@ -29,6 +31,7 @@ describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.r
after :each do
Puppet::Rails.teardown
+ ActiveRecord::Base.remove_connection
end
describe "#save" do
diff --git a/spec/unit/indirector/facts/rest_spec.rb b/spec/unit/indirector/facts/rest_spec.rb
index 03bef4578..6a2a23f8b 100755
--- a/spec/unit/indirector/facts/rest_spec.rb
+++ b/spec/unit/indirector/facts/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/facts/rest'
diff --git a/spec/unit/indirector/facts/yaml_spec.rb b/spec/unit/indirector/facts/yaml_spec.rb
index c266df18f..a22d690b8 100755
--- a/spec/unit/indirector/facts/yaml_spec.rb
+++ b/spec/unit/indirector/facts/yaml_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/node/facts'
require 'puppet/indirector/facts/yaml'
diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb
index 1423cb2e3..e0612cb21 100755
--- a/spec/unit/indirector/file_bucket_file/file_spec.rb
+++ b/spec/unit/indirector/file_bucket_file/file_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require ::File.dirname(__FILE__) + '/../../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/file_bucket_file/file'
diff --git a/spec/unit/indirector/file_bucket_file/rest_spec.rb b/spec/unit/indirector/file_bucket_file/rest_spec.rb
index d0f714751..ae2e033c6 100755
--- a/spec/unit/indirector/file_bucket_file/rest_spec.rb
+++ b/spec/unit/indirector/file_bucket_file/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/file_bucket_file/rest'
diff --git a/spec/unit/indirector/file_content/file_server_spec.rb b/spec/unit/indirector/file_content/file_server_spec.rb
index 5bd88132c..99a535dc3 100755
--- a/spec/unit/indirector/file_content/file_server_spec.rb
+++ b/spec/unit/indirector/file_content/file_server_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-18.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/file_content/file_server'
diff --git a/spec/unit/indirector/file_content/file_spec.rb b/spec/unit/indirector/file_content/file_spec.rb
index edead1c70..b629981c5 100755
--- a/spec/unit/indirector/file_content/file_spec.rb
+++ b/spec/unit/indirector/file_content/file_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-18.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/file_content/file'
diff --git a/spec/unit/indirector/file_content/rest_spec.rb b/spec/unit/indirector/file_content/rest_spec.rb
index cf94d2ffd..06ad16e77 100755
--- a/spec/unit/indirector/file_content/rest_spec.rb
+++ b/spec/unit/indirector/file_content/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/file_content'
diff --git a/spec/unit/indirector/file_metadata/file_server_spec.rb b/spec/unit/indirector/file_metadata/file_server_spec.rb
index 99eb83d7f..e16829035 100755
--- a/spec/unit/indirector/file_metadata/file_server_spec.rb
+++ b/spec/unit/indirector/file_metadata/file_server_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-18.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/file_metadata/file_server'
diff --git a/spec/unit/indirector/file_metadata/file_spec.rb b/spec/unit/indirector/file_metadata/file_spec.rb
index 74eff5b66..28a974290 100755
--- a/spec/unit/indirector/file_metadata/file_spec.rb
+++ b/spec/unit/indirector/file_metadata/file_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-18.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/file_metadata/file'
diff --git a/spec/unit/indirector/file_metadata/rest_spec.rb b/spec/unit/indirector/file_metadata/rest_spec.rb
index 132d90d4f..511f7c758 100755
--- a/spec/unit/indirector/file_metadata/rest_spec.rb
+++ b/spec/unit/indirector/file_metadata/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/file_metadata'
diff --git a/spec/unit/indirector/file_server_spec.rb b/spec/unit/indirector/file_server_spec.rb
index 079eba0ae..6df715fb1 100755
--- a/spec/unit/indirector/file_server_spec.rb
+++ b/spec/unit/indirector/file_server_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-10-19.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/file_server'
require 'puppet/file_serving/configuration'
diff --git a/spec/unit/indirector/file_spec.rb b/spec/unit/indirector/file_spec.rb
index 96d5b2ae7..b72bf4d67 100755
--- a/spec/unit/indirector/file_spec.rb
+++ b/spec/unit/indirector/file_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/file'
diff --git a/spec/unit/indirector/indirection_spec.rb b/spec/unit/indirector/indirection_spec.rb
index 8795ae795..4bbc855b1 100755
--- a/spec/unit/indirector/indirection_spec.rb
+++ b/spec/unit/indirector/indirection_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/indirection'
diff --git a/spec/unit/indirector/inventory/yaml_spec.rb b/spec/unit/indirector/inventory/yaml_spec.rb
index a4eb2ab7a..54ab9c72c 100644..100755
--- a/spec/unit/indirector/inventory/yaml_spec.rb
+++ b/spec/unit/indirector/inventory/yaml_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/node/inventory'
require 'puppet/indirector/inventory/yaml'
diff --git a/spec/unit/indirector/key/ca_spec.rb b/spec/unit/indirector/key/ca_spec.rb
index 53bd380a6..ba3d1aae2 100755
--- a/spec/unit/indirector/key/ca_spec.rb
+++ b/spec/unit/indirector/key/ca_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/key/ca'
diff --git a/spec/unit/indirector/key/file_spec.rb b/spec/unit/indirector/key/file_spec.rb
index 715ceacda..bf9b293d8 100755
--- a/spec/unit/indirector/key/file_spec.rb
+++ b/spec/unit/indirector/key/file_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-7.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/key/file'
diff --git a/spec/unit/indirector/ldap_spec.rb b/spec/unit/indirector/ldap_spec.rb
index ab5dab9ce..2b40325de 100755
--- a/spec/unit/indirector/ldap_spec.rb
+++ b/spec/unit/indirector/ldap_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/ldap'
diff --git a/spec/unit/indirector/memory_spec.rb b/spec/unit/indirector/memory_spec.rb
index 751adb1b6..676acfcca 100755
--- a/spec/unit/indirector/memory_spec.rb
+++ b/spec/unit/indirector/memory_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/memory'
require 'shared_behaviours/memory_terminus'
diff --git a/spec/unit/indirector/node/active_record_spec.rb b/spec/unit/indirector/node/active_record_spec.rb
index 65b0e1fc9..6fed940b9 100755
--- a/spec/unit/indirector/node/active_record_spec.rb
+++ b/spec/unit/indirector/node/active_record_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/node'
diff --git a/spec/unit/indirector/node/exec_spec.rb b/spec/unit/indirector/node/exec_spec.rb
index e6d6ccb93..f14990cd5 100755
--- a/spec/unit/indirector/node/exec_spec.rb
+++ b/spec/unit/indirector/node/exec_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/node/exec'
diff --git a/spec/unit/indirector/node/ldap_spec.rb b/spec/unit/indirector/node/ldap_spec.rb
index 5d4086a1a..5e57db3c4 100755
--- a/spec/unit/indirector/node/ldap_spec.rb
+++ b/spec/unit/indirector/node/ldap_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/node/ldap'
diff --git a/spec/unit/indirector/node/memory_spec.rb b/spec/unit/indirector/node/memory_spec.rb
index 904ee1259..8b26a47c1 100755
--- a/spec/unit/indirector/node/memory_spec.rb
+++ b/spec/unit/indirector/node/memory_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/node/memory'
diff --git a/spec/unit/indirector/node/plain_spec.rb b/spec/unit/indirector/node/plain_spec.rb
index 40d5211db..c6ba84e67 100755
--- a/spec/unit/indirector/node/plain_spec.rb
+++ b/spec/unit/indirector/node/plain_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/node/plain'
diff --git a/spec/unit/indirector/node/rest_spec.rb b/spec/unit/indirector/node/rest_spec.rb
index cb3012efa..fa5d1baf7 100755
--- a/spec/unit/indirector/node/rest_spec.rb
+++ b/spec/unit/indirector/node/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/node/rest'
diff --git a/spec/unit/indirector/node/yaml_spec.rb b/spec/unit/indirector/node/yaml_spec.rb
index 649bde06d..db9ffe435 100755
--- a/spec/unit/indirector/node/yaml_spec.rb
+++ b/spec/unit/indirector/node/yaml_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/node'
require 'puppet/indirector/node/yaml'
diff --git a/spec/unit/indirector/plain_spec.rb b/spec/unit/indirector/plain_spec.rb
index dfaa701bd..0894f70f0 100755
--- a/spec/unit/indirector/plain_spec.rb
+++ b/spec/unit/indirector/plain_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/plain'
describe Puppet::Indirector::Plain do
diff --git a/spec/unit/indirector/queue_spec.rb b/spec/unit/indirector/queue_spec.rb
index 6f5b44b4c..b84ed2aea 100755
--- a/spec/unit/indirector/queue_spec.rb
+++ b/spec/unit/indirector/queue_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/queue'
class Puppet::Indirector::Queue::TestClient
diff --git a/spec/unit/indirector/report/processor_spec.rb b/spec/unit/indirector/report/processor_spec.rb
index adc2638fc..bafbe6ee7 100755
--- a/spec/unit/indirector/report/processor_spec.rb
+++ b/spec/unit/indirector/report/processor_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-9-23.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/report/processor'
diff --git a/spec/unit/indirector/report/rest_spec.rb b/spec/unit/indirector/report/rest_spec.rb
index 67a98e334..806ae6efd 100755
--- a/spec/unit/indirector/report/rest_spec.rb
+++ b/spec/unit/indirector/report/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/report/rest'
diff --git a/spec/unit/indirector/report/yaml_spec.rb b/spec/unit/indirector/report/yaml_spec.rb
index e75fafe5e..7df4bb2e9 100644..100755
--- a/spec/unit/indirector/report/yaml_spec.rb
+++ b/spec/unit/indirector/report/yaml_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/transaction/report'
require 'puppet/indirector/report/yaml'
diff --git a/spec/unit/indirector/request_spec.rb b/spec/unit/indirector/request_spec.rb
index bef56b1e1..965d54188 100755
--- a/spec/unit/indirector/request_spec.rb
+++ b/spec/unit/indirector/request_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/request'
describe Puppet::Indirector::Request do
diff --git a/spec/unit/indirector/resource/ral_spec.rb b/spec/unit/indirector/resource/ral_spec.rb
index 43deaa8eb..61290f7a7 100644..100755
--- a/spec/unit/indirector/resource/ral_spec.rb
+++ b/spec/unit/indirector/resource/ral_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "Puppet::Resource::Ral" do
describe "find" do
diff --git a/spec/unit/indirector/resource/rest_spec.rb b/spec/unit/indirector/resource/rest_spec.rb
index 1285d338a..70c9a7f11 100755
--- a/spec/unit/indirector/resource/rest_spec.rb
+++ b/spec/unit/indirector/resource/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/resource/rest'
diff --git a/spec/unit/indirector/resource_type/parser_spec.rb b/spec/unit/indirector/resource_type/parser_spec.rb
index f86b319f9..c4fc455a0 100755
--- a/spec/unit/indirector/resource_type/parser_spec.rb
+++ b/spec/unit/indirector/resource_type/parser_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/resource_type/parser'
require 'puppet_spec/files'
diff --git a/spec/unit/indirector/resource_type/rest_spec.rb b/spec/unit/indirector/resource_type/rest_spec.rb
index dceb109b2..3d8ddf44c 100755
--- a/spec/unit/indirector/resource_type/rest_spec.rb
+++ b/spec/unit/indirector/resource_type/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/resource_type/rest'
diff --git a/spec/unit/indirector/rest_spec.rb b/spec/unit/indirector/rest_spec.rb
index 326d85f9d..513eb8352 100755
--- a/spec/unit/indirector/rest_spec.rb
+++ b/spec/unit/indirector/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/rest'
shared_examples_for "a REST http call" do
@@ -224,13 +223,32 @@ describe Puppet::Indirector::REST do
@searcher.stubs(:network).returns(@connection) # neuter the network connection
# Use a key with spaces, so we can test escaping
- @request = Puppet::Indirector::Request.new(:foo, :find, "foo bar")
+ @request = Puppet::Indirector::Request.new(:foo, :find, "foo bar", :environment => "myenv")
end
- it "should call the GET http method on a network connection" do
- @searcher.expects(:network).returns @connection
- @connection.expects(:get).returns @response
- @searcher.find(@request)
+ describe "with a large body" do
+ it "should use the POST http method" do
+ params = {}
+ 'aa'.upto('zz') do |s|
+ params[s] = 'foo'
+ end
+
+ @request = Puppet::Indirector::Request.new(:foo, :find, "foo bar", params.merge(:environment => "myenv"))
+
+ @connection.expects(:post).with do |uri, body|
+ uri == "/myenv/foo/foo%20bar" and body.split("&").sort == params.map {|key,value| "#{key}=#{value}"}.sort
+ end.returns(@response)
+
+ @searcher.find(@request)
+ end
+ end
+
+ describe "with a small body" do
+ it "should use the GET http method" do
+ @searcher.expects(:network).returns @connection
+ @connection.expects(:get).returns @response
+ @searcher.find(@request)
+ end
end
it "should deserialize and return the http response, setting name" do
@@ -252,10 +270,8 @@ describe Puppet::Indirector::REST do
@searcher.find(@request).should == instance
end
-
it "should use the URI generated by the Handler module" do
- @searcher.expects(:indirection2uri).with(@request).returns "/my/uri"
- @connection.expects(:get).with { |path, args| path == "/my/uri" }.returns(@response)
+ @connection.expects(:get).with { |path, args| path == "/myenv/foo/foo%20bar?" }.returns(@response)
@searcher.find(@request)
end
diff --git a/spec/unit/indirector/run/local_spec.rb b/spec/unit/indirector/run/local_spec.rb
index cb012a0b0..8fb61d962 100644..100755
--- a/spec/unit/indirector/run/local_spec.rb
+++ b/spec/unit/indirector/run/local_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/run/local'
diff --git a/spec/unit/indirector/run/rest_spec.rb b/spec/unit/indirector/run/rest_spec.rb
index cf90caa5b..4b80962d1 100755
--- a/spec/unit/indirector/run/rest_spec.rb
+++ b/spec/unit/indirector/run/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/run/rest'
diff --git a/spec/unit/indirector/ssl_file_spec.rb b/spec/unit/indirector/ssl_file_spec.rb
index ca97cf49e..5d0859598 100755
--- a/spec/unit/indirector/ssl_file_spec.rb
+++ b/spec/unit/indirector/ssl_file_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-10.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/indirector/ssl_file'
diff --git a/spec/unit/indirector/status/rest_spec.rb b/spec/unit/indirector/status/rest_spec.rb
index 436c86881..b203e6e20 100755
--- a/spec/unit/indirector/status/rest_spec.rb
+++ b/spec/unit/indirector/status/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/status/rest'
diff --git a/spec/unit/indirector/terminus_spec.rb b/spec/unit/indirector/terminus_spec.rb
index bc255aa5b..41770e1e3 100755
--- a/spec/unit/indirector/terminus_spec.rb
+++ b/spec/unit/indirector/terminus_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/defaults'
require 'puppet/indirector'
require 'puppet/indirector/file'
diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb
index 188e300d6..c43dbcaf6 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/indirector/yaml'
diff --git a/spec/unit/indirector_spec.rb b/spec/unit/indirector_spec.rb
index 7bab426c0..0c09831db 100755
--- a/spec/unit/indirector_spec.rb
+++ b/spec/unit/indirector_spec.rb
@@ -1,10 +1,68 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/defaults'
require 'puppet/indirector'
+describe Puppet::Indirector, "when configuring routes" do
+ before :each do
+ Puppet::Node.indirection.reset_terminus_class
+ Puppet::Node.indirection.cache_class = nil
+ end
+
+ after :each do
+ Puppet::Node.indirection.reset_terminus_class
+ Puppet::Node.indirection.cache_class = nil
+ end
+
+ it "should configure routes as requested" do
+ routes = {
+ "node" => {
+ "terminus" => "exec",
+ "cache" => "plain"
+ }
+ }
+
+ Puppet::Indirector.configure_routes(routes)
+
+ Puppet::Node.indirection.terminus_class.should == "exec"
+ Puppet::Node.indirection.cache_class.should == "plain"
+ end
+
+ it "should fail when given an invalid indirection" do
+ routes = {
+ "fake_indirection" => {
+ "terminus" => "exec",
+ "cache" => "plain"
+ }
+ }
+
+ expect { Puppet::Indirector.configure_routes(routes) }.should raise_error(/fake_indirection does not exist/)
+ end
+
+ it "should fail when given an invalid terminus" do
+ routes = {
+ "node" => {
+ "terminus" => "fake_terminus",
+ "cache" => "plain"
+ }
+ }
+
+ expect { Puppet::Indirector.configure_routes(routes) }.should raise_error(/Could not find terminus fake_terminus/)
+ end
+
+ it "should fail when given an invalid cache" do
+ routes = {
+ "node" => {
+ "terminus" => "exec",
+ "cache" => "fake_cache"
+ }
+ }
+
+ expect { Puppet::Indirector.configure_routes(routes) }.should raise_error(/Could not find terminus fake_cache/)
+ end
+end
+
describe Puppet::Indirector, " when available to a model" do
before do
@thingie = Class.new do
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb
new file mode 100755
index 000000000..5b04df900
--- /dev/null
+++ b/spec/unit/interface/action_builder_spec.rb
@@ -0,0 +1,69 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/interface/action_builder'
+
+describe Puppet::Interface::ActionBuilder do
+ describe "::build" do
+ it "should build an action" do
+ action = Puppet::Interface::ActionBuilder.build(nil, :foo) do
+ end
+ action.should be_a(Puppet::Interface::Action)
+ action.name.should == :foo
+ end
+
+ it "should define a method on the face which invokes the action" do
+ face = Puppet::Interface.new(:action_builder_test_interface, '0.0.1')
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+ when_invoked do
+ "invoked the method"
+ end
+ end
+
+ face.foo.should == "invoked the method"
+ end
+
+ it "should require a block" do
+ expect { Puppet::Interface::ActionBuilder.build(nil, :foo) }.
+ should raise_error("Action :foo must specify a block")
+ end
+
+ describe "when handling options" do
+ let :face do Puppet::Interface.new(:option_handling, '0.0.1') end
+
+ it "should have a #option DSL function" do
+ method = nil
+ Puppet::Interface::ActionBuilder.build(face, :foo) do
+ method = self.method(:option)
+ end
+ method.should be
+ end
+
+ it "should define an option without a block" do
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+ option "--bar"
+ end
+ action.should be_option :bar
+ end
+
+ it "should accept an empty block" do
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+ option "--bar" do
+ # This space left deliberately blank.
+ end
+ end
+ action.should be_option :bar
+ end
+ end
+
+ context "inline documentation" do
+ let :face do Puppet::Interface.new(:inline_action_docs, '0.0.1') end
+
+ it "should set the summary" do
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+ summary "this is some text"
+ end
+ action.summary.should == "this is some text"
+ end
+ end
+ end
+end
diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb
new file mode 100755
index 000000000..c4b21eaac
--- /dev/null
+++ b/spec/unit/interface/action_manager_spec.rb
@@ -0,0 +1,232 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+# This is entirely an internal class for Interface, so we have to load it instead of our class.
+require 'puppet/interface'
+
+class ActionManagerTester
+ include Puppet::Interface::ActionManager
+end
+
+describe Puppet::Interface::ActionManager do
+ subject { ActionManagerTester.new }
+
+ describe "when included in a class" do
+ it "should be able to define an action" do
+ subject.action(:foo) do
+ when_invoked { "something "}
+ end
+ end
+
+ it "should be able to define a 'script' style action" do
+ subject.script :bar do
+ "a bar is where beer is found"
+ end
+ end
+
+ it "should be able to list defined actions" do
+ subject.action(:foo) do
+ when_invoked { "something" }
+ end
+ subject.action(:bar) do
+ when_invoked { "something" }
+ end
+
+ subject.actions.should =~ [:foo, :bar]
+ end
+
+ it "should list 'script' actions" do
+ subject.script :foo do "foo" end
+ subject.actions.should =~ [:foo]
+ end
+
+ it "should list both script and normal actions" do
+ subject.action :foo do
+ when_invoked do "foo" end
+ end
+ subject.script :bar do "a bar is where beer is found" end
+
+ subject.actions.should =~ [:foo, :bar]
+ end
+
+ it "should be able to indicate when an action is defined" do
+ subject.action(:foo) do
+ when_invoked { "something" }
+ end
+
+ subject.should be_action(:foo)
+ end
+
+ it "should indicate an action is defined for script actions" do
+ subject.script :foo do "foo" end
+ subject.should be_action :foo
+ end
+
+ it "should correctly treat action names specified as strings" do
+ subject.action(:foo) do
+ when_invoked { "something" }
+ end
+
+ subject.should be_action("foo")
+ end
+ end
+
+ describe "when used to extend a class" do
+ subject { Class.new.extend(Puppet::Interface::ActionManager) }
+
+ it "should be able to define an action" do
+ subject.action(:foo) do
+ when_invoked { "something "}
+ end
+ end
+
+ it "should be able to list defined actions" do
+ subject.action(:foo) do
+ when_invoked { "something" }
+ end
+ subject.action(:bar) do
+ when_invoked { "something" }
+ end
+
+ subject.actions.should include(:bar)
+ subject.actions.should include(:foo)
+ end
+
+ it "should be able to indicate when an action is defined" do
+ subject.action(:foo) { "something" }
+ subject.should be_action(:foo)
+ end
+ end
+
+ describe "when used both at the class and instance level" do
+ before do
+ @klass = Class.new do
+ include Puppet::Interface::ActionManager
+ extend Puppet::Interface::ActionManager
+ end
+ @instance = @klass.new
+ end
+
+ it "should be able to define an action at the class level" do
+ @klass.action(:foo) do
+ when_invoked { "something "}
+ end
+ end
+
+ it "should create an instance method when an action is defined at the class level" do
+ @klass.action(:foo) do
+ when_invoked { "something" }
+ end
+ @instance.foo.should == "something"
+ end
+
+ it "should be able to define an action at the instance level" do
+ @instance.action(:foo) do
+ when_invoked { "something "}
+ end
+ end
+
+ it "should create an instance method when an action is defined at the instance level" do
+ @instance.action(:foo) do
+ when_invoked { "something" }
+ end
+ @instance.foo.should == "something"
+ end
+
+ it "should be able to list actions defined at the class level" do
+ @klass.action(:foo) do
+ when_invoked { "something" }
+ end
+ @klass.action(:bar) do
+ when_invoked { "something" }
+ end
+
+ @klass.actions.should include(:bar)
+ @klass.actions.should include(:foo)
+ end
+
+ it "should be able to list actions defined at the instance level" do
+ @instance.action(:foo) do
+ when_invoked { "something" }
+ end
+ @instance.action(:bar) do
+ when_invoked { "something" }
+ end
+
+ @instance.actions.should include(:bar)
+ @instance.actions.should include(:foo)
+ end
+
+ it "should be able to list actions defined at both instance and class level" do
+ @klass.action(:foo) do
+ when_invoked { "something" }
+ end
+ @instance.action(:bar) do
+ when_invoked { "something" }
+ end
+
+ @instance.actions.should include(:bar)
+ @instance.actions.should include(:foo)
+ end
+
+ it "should be able to indicate when an action is defined at the class level" do
+ @klass.action(:foo) do
+ when_invoked { "something" }
+ end
+ @instance.should be_action(:foo)
+ end
+
+ it "should be able to indicate when an action is defined at the instance level" do
+ @klass.action(:foo) do
+ when_invoked { "something" }
+ end
+ @instance.should be_action(:foo)
+ end
+
+ it "should list actions defined in superclasses" do
+ @subclass = Class.new(@klass)
+ @instance = @subclass.new
+
+ @klass.action(:parent) do
+ when_invoked { "a" }
+ end
+ @subclass.action(:sub) do
+ when_invoked { "a" }
+ end
+ @instance.action(:instance) do
+ when_invoked { "a" }
+ end
+
+ @instance.should be_action(:parent)
+ @instance.should be_action(:sub)
+ @instance.should be_action(:instance)
+ end
+
+ it "should create an instance method when an action is defined in a superclass" do
+ @subclass = Class.new(@klass)
+ @instance = @subclass.new
+
+ @klass.action(:foo) do
+ when_invoked { "something" }
+ end
+ @instance.foo.should == "something"
+ end
+ end
+
+ describe "#get_action" do
+ let :parent_class do
+ parent_class = Class.new(Puppet::Interface)
+ parent_class.action(:foo) {}
+ parent_class
+ end
+
+ it "should check that we can find inherited actions when we are a class" do
+ Class.new(parent_class).get_action(:foo).name.should == :foo
+ end
+
+ it "should check that we can find inherited actions when we are an instance" do
+ instance = parent_class.new(:foo, '0.0.0')
+ instance.get_action(:foo).name.should == :foo
+ end
+ end
+end
diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb
new file mode 100755
index 000000000..8c6782976
--- /dev/null
+++ b/spec/unit/interface/action_spec.rb
@@ -0,0 +1,172 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/interface/action'
+
+describe Puppet::Interface::Action do
+ describe "when validating the action name" do
+ [nil, '', 'foo bar', '-foobar'].each do |input|
+ it "should treat #{input.inspect} as an invalid name" do
+ expect { Puppet::Interface::Action.new(nil, input) }.
+ should raise_error(/is an invalid action name/)
+ end
+ end
+ end
+
+ describe "when invoking" do
+ it "should be able to call other actions on the same object" do
+ face = Puppet::Interface.new(:my_face, '0.0.1') do
+ action(:foo) do
+ when_invoked { 25 }
+ end
+
+ action(:bar) do
+ when_invoked { "the value of foo is '#{foo}'" }
+ end
+ end
+ face.foo.should == 25
+ face.bar.should == "the value of foo is '25'"
+ end
+
+ # bar is a class action calling a class action
+ # quux is a class action calling an instance action
+ # baz is an instance action calling a class action
+ # qux is an instance action calling an instance action
+ it "should be able to call other actions on the same object when defined on a class" do
+ class Puppet::Interface::MyInterfaceBaseClass < Puppet::Interface
+ action(:foo) do
+ when_invoked { 25 }
+ end
+
+ action(:bar) do
+ when_invoked { "the value of foo is '#{foo}'" }
+ end
+
+ action(:quux) do
+ when_invoked { "qux told me #{qux}" }
+ end
+ end
+
+ face = Puppet::Interface::MyInterfaceBaseClass.new(:my_inherited_face, '0.0.1') do
+ action(:baz) do
+ when_invoked { "the value of foo in baz is '#{foo}'" }
+ end
+
+ action(:qux) do
+ when_invoked { baz }
+ end
+ end
+ face.foo.should == 25
+ face.bar.should == "the value of foo is '25'"
+ face.quux.should == "qux told me the value of foo in baz is '25'"
+ face.baz.should == "the value of foo in baz is '25'"
+ face.qux.should == "the value of foo in baz is '25'"
+ end
+
+ context "when calling the Ruby API" do
+ let :face do
+ Puppet::Interface.new(:ruby_api, '1.0.0') do
+ action :bar do
+ when_invoked do |options|
+ options
+ end
+ end
+ end
+ end
+
+ it "should work when no options are supplied" do
+ options = face.bar
+ options.should == {}
+ end
+
+ it "should work when options are supplied" do
+ options = face.bar :bar => "beer"
+ options.should == { :bar => "beer" }
+ end
+ end
+ end
+
+ describe "with action-level options" do
+ it "should support options with an empty block" do
+ face = Puppet::Interface.new(:action_level_options, '0.0.1') do
+ action :foo do
+ option "--bar" do
+ # this line left deliberately blank
+ end
+ end
+ end
+
+ face.should_not be_option :bar
+ face.get_action(:foo).should be_option :bar
+ end
+
+ it "should return only action level options when there are no face options" do
+ face = Puppet::Interface.new(:action_level_options, '0.0.1') do
+ action :foo do option "--bar" end
+ end
+
+ face.get_action(:foo).options.should =~ [:bar]
+ end
+
+ describe "with both face and action options" do
+ let :face do
+ Puppet::Interface.new(:action_level_options, '0.0.1') do
+ action :foo do option "--bar" end
+ action :baz do option "--bim" end
+ option "--quux"
+ end
+ end
+
+ it "should return combined face and action options" do
+ face.get_action(:foo).options.should =~ [:bar, :quux]
+ end
+
+ it "should fetch options that the face inherited" do
+ parent = Class.new(Puppet::Interface)
+ parent.option "--foo"
+ child = parent.new(:inherited_options, '0.0.1') do
+ option "--bar"
+ action :action do option "--baz" end
+ end
+
+ action = child.get_action(:action)
+ action.should be
+
+ [:baz, :bar, :foo].each do |name|
+ action.get_option(name).should be_an_instance_of Puppet::Interface::Option
+ end
+ end
+
+ it "should get an action option when asked" do
+ face.get_action(:foo).get_option(:bar).
+ should be_an_instance_of Puppet::Interface::Option
+ end
+
+ it "should get a face option when asked" do
+ face.get_action(:foo).get_option(:quux).
+ should be_an_instance_of Puppet::Interface::Option
+ end
+
+ it "should return options only for this action" do
+ face.get_action(:baz).options.should =~ [:bim, :quux]
+ end
+ end
+
+ it_should_behave_like "things that declare options" do
+ def add_options_to(&block)
+ face = Puppet::Interface.new(:with_options, '0.0.1') do
+ action(:foo, &block)
+ end
+ face.get_action(:foo)
+ end
+ end
+
+ it "should fail when a face option duplicates an action option" do
+ expect {
+ Puppet::Interface.new(:action_level_options, '0.0.1') do
+ option "--foo"
+ action :bar do option "--foo" end
+ end
+ }.should raise_error ArgumentError, /Option foo conflicts with existing option foo/i
+ end
+ end
+end
diff --git a/spec/unit/interface/face_collection_spec.rb b/spec/unit/interface/face_collection_spec.rb
new file mode 100755
index 000000000..d1114dde7
--- /dev/null
+++ b/spec/unit/interface/face_collection_spec.rb
@@ -0,0 +1,170 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+require 'tmpdir'
+require 'puppet/interface/face_collection'
+
+describe Puppet::Interface::FaceCollection do
+ # To avoid cross-pollution we have to save and restore both the hash
+ # containing all the interface data, and the array used by require. Restoring
+ # both means that we don't leak side-effects across the code. --daniel 2011-04-06
+ #
+ # Worse luck, we *also* need to flush $" of anything defining a face,
+ # because otherwise we can cross-pollute from other test files and end up
+ # with no faces loaded, but the require value set true. --daniel 2011-04-10
+ before :each do
+ @original_faces = subject.instance_variable_get("@faces").dup
+ @original_required = $".dup
+ $".delete_if do |path| path =~ %r{/face/.*\.rb$} end
+ subject.instance_variable_get("@faces").clear
+ end
+
+ after :each do
+ subject.instance_variable_set("@faces", @original_faces)
+ $".clear ; @original_required.each do |item| $" << item end
+ end
+
+ describe "::faces" do
+ it "REVISIT: should have some tests here, if we describe it"
+ end
+
+ describe "::validate_version" do
+ it 'should permit three number versions' do
+ subject.validate_version('10.10.10').should == true
+ end
+
+ it 'should permit versions with appended descriptions' do
+ subject.validate_version('10.10.10beta').should == true
+ end
+
+ it 'should not permit versions with more than three numbers' do
+ subject.validate_version('1.2.3.4').should == false
+ end
+
+ it 'should not permit versions with only two numbers' do
+ subject.validate_version('10.10').should == false
+ end
+
+ it 'should not permit versions with only one number' do
+ subject.validate_version('123').should == false
+ end
+
+ it 'should not permit versions with text in any position but at the end' do
+ subject.validate_version('v1.1.1').should == false
+ end
+ end
+
+ describe "::[]" do
+ before :each do
+ subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10
+ end
+
+ it "should return the face with the given name" do
+ subject["foo", '0.0.1'].should == 10
+ end
+
+ it "should attempt to load the face if it isn't found" do
+ subject.expects(:require).with('puppet/face/bar')
+ subject["bar", '0.0.1']
+ end
+
+ it "should attempt to load the default face for the specified version :current" do
+ subject.expects(:require).with('puppet/face/fozzie')
+ subject['fozzie', :current]
+ end
+ end
+
+ describe "::face?" do
+ it "should return true if the face specified is registered" do
+ subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10
+ subject.face?("foo", '0.0.1').should == true
+ end
+
+ it "should attempt to require the face if it is not registered" do
+ subject.expects(:require).with do |file|
+ subject.instance_variable_get("@faces")[:bar]['0.0.1'] = true
+ file == 'puppet/face/bar'
+ end
+ subject.face?("bar", '0.0.1').should == true
+ end
+
+ it "should return true if requiring the face registered it" do
+ subject.stubs(:require).with do
+ subject.instance_variable_get("@faces")[:bar]['0.0.1'] = 20
+ end
+ end
+
+ it "should return false if the face is not registered" do
+ subject.stubs(:require).returns(true)
+ subject.face?("bar", '0.0.1').should be_false
+ end
+
+ it "should return false if the face file itself is missing" do
+ subject.stubs(:require).
+ raises(LoadError, 'no such file to load -- puppet/face/bar')
+ subject.face?("bar", '0.0.1').should be_false
+ end
+
+ it "should register the version loaded by `:current` as `:current`" do
+ subject.expects(:require).with do |file|
+ subject.instance_variable_get("@faces")[:huzzah]['2.0.1'] = :huzzah_face
+ file == 'puppet/face/huzzah'
+ end
+ subject.face?("huzzah", :current)
+ subject.instance_variable_get("@faces")[:huzzah][:current].should == :huzzah_face
+ end
+
+ context "with something on disk" do
+ it "should register the version loaded from `puppet/face/{name}` as `:current`" do
+ subject.should be_face "huzzah", '2.0.1'
+ subject.should be_face "huzzah", :current
+ Puppet::Face[:huzzah, '2.0.1'].should == Puppet::Face[:huzzah, :current]
+ end
+
+ it "should index :current when the code was pre-required" do
+ subject.instance_variable_get("@faces")[:huzzah].should_not be_key :current
+ require 'puppet/face/huzzah'
+ subject.face?(:huzzah, :current).should be_true
+ end
+ end
+
+ it "should not cause an invalid face to be enumerated later" do
+ subject.face?(:there_is_no_face, :current).should be_false
+ subject.faces.should_not include :there_is_no_face
+ end
+ end
+
+ describe "::register" do
+ it "should store the face by name" do
+ face = Puppet::Face.new(:my_face, '0.0.1')
+ subject.register(face)
+ subject.instance_variable_get("@faces").should == {:my_face => {'0.0.1' => face}}
+ end
+ end
+
+ describe "::underscorize" do
+ faulty = [1, "#foo", "$bar", "sturm und drang", :"sturm und drang"]
+ valid = {
+ "Foo" => :foo,
+ :Foo => :foo,
+ "foo_bar" => :foo_bar,
+ :foo_bar => :foo_bar,
+ "foo-bar" => :foo_bar,
+ :"foo-bar" => :foo_bar,
+ }
+
+ valid.each do |input, expect|
+ it "should map #{input.inspect} to #{expect.inspect}" do
+ result = subject.underscorize(input)
+ result.should == expect
+ end
+ end
+
+ faulty.each do |input|
+ it "should fail when presented with #{input.inspect} (#{input.class})" do
+ expect { subject.underscorize(input) }.
+ should raise_error ArgumentError, /not a valid face name/
+ end
+ end
+ end
+end
diff --git a/spec/unit/interface/option_builder_spec.rb b/spec/unit/interface/option_builder_spec.rb
new file mode 100755
index 000000000..fae48324e
--- /dev/null
+++ b/spec/unit/interface/option_builder_spec.rb
@@ -0,0 +1,29 @@
+require 'puppet/interface/option_builder'
+
+describe Puppet::Interface::OptionBuilder do
+ let :face do Puppet::Interface.new(:option_builder_testing, '0.0.1') end
+
+ it "should be able to construct an option without a block" do
+ Puppet::Interface::OptionBuilder.build(face, "--foo").
+ should be_an_instance_of Puppet::Interface::Option
+ end
+
+ describe "when using the DSL block" do
+ it "should work with an empty block" do
+ option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ # This block deliberately left blank.
+ end
+
+ option.should be_an_instance_of Puppet::Interface::Option
+ end
+
+ it "should support documentation declarations" do
+ text = "this is the description"
+ option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ desc text
+ end
+ option.should be_an_instance_of Puppet::Interface::Option
+ option.desc.should == text
+ end
+ end
+end
diff --git a/spec/unit/interface/option_spec.rb b/spec/unit/interface/option_spec.rb
new file mode 100755
index 000000000..3bcd121e2
--- /dev/null
+++ b/spec/unit/interface/option_spec.rb
@@ -0,0 +1,75 @@
+require 'puppet/interface/option'
+
+describe Puppet::Interface::Option do
+ let :face do Puppet::Interface.new(:option_testing, '0.0.1') end
+
+ describe "#optparse_to_name" do
+ ["", "=BAR", " BAR", "=bar", " bar"].each do |postfix|
+ { "--foo" => :foo, "-f" => :f }.each do |base, expect|
+ input = base + postfix
+ it "should map #{input.inspect} to #{expect.inspect}" do
+ option = Puppet::Interface::Option.new(face, input)
+ option.name.should == expect
+ end
+ end
+ end
+
+ [:foo, 12, nil, {}, []].each do |input|
+ it "should fail sensible when given #{input.inspect}" do
+ expect { Puppet::Interface::Option.new(face, input) }.
+ should raise_error ArgumentError, /is not valid for an option argument/
+ end
+ end
+
+ ["-foo", "-foo=BAR", "-foo BAR"].each do |input|
+ it "should fail with a single dash for long option #{input.inspect}" do
+ expect { Puppet::Interface::Option.new(face, input) }.
+ should raise_error ArgumentError, /long options need two dashes \(--\)/
+ end
+ end
+ end
+
+ it "requires a face when created" do
+ expect { Puppet::Interface::Option.new }.
+ should raise_error ArgumentError, /wrong number of arguments/
+ end
+
+ it "also requires some declaration arguments when created" do
+ expect { Puppet::Interface::Option.new(face) }.
+ should raise_error ArgumentError, /No option declarations found/
+ end
+
+ it "should infer the name from an optparse string" do
+ option = Puppet::Interface::Option.new(face, "--foo")
+ option.name.should == :foo
+ end
+
+ it "should infer the name when multiple optparse string are given" do
+ option = Puppet::Interface::Option.new(face, "--foo", "-f")
+ option.name.should == :foo
+ end
+
+ it "should prefer the first long option name over a short option name" do
+ option = Puppet::Interface::Option.new(face, "-f", "--foo")
+ option.name.should == :foo
+ end
+
+ it "should create an instance when given a face and name" do
+ Puppet::Interface::Option.new(face, "--foo").
+ should be_instance_of Puppet::Interface::Option
+ end
+
+ describe "#to_s" do
+ it "should transform a symbol into a string" do
+ option = Puppet::Interface::Option.new(face, "--foo")
+ option.name.should == :foo
+ option.to_s.should == "foo"
+ end
+
+ it "should use - rather than _ to separate words in strings but not symbols" do
+ option = Puppet::Interface::Option.new(face, "--foo-bar")
+ option.name.should == :foo_bar
+ option.to_s.should == "foo-bar"
+ end
+ end
+end
diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb
new file mode 100755
index 000000000..e52b45d8a
--- /dev/null
+++ b/spec/unit/interface_spec.rb
@@ -0,0 +1,207 @@
+require 'spec_helper'
+require 'puppet/face'
+require 'puppet/interface'
+
+describe Puppet::Interface do
+ subject { Puppet::Interface }
+
+ before :all do
+ @faces = Puppet::Interface::FaceCollection.instance_variable_get("@faces").dup
+ end
+
+ before :each do
+ Puppet::Interface::FaceCollection.instance_variable_get("@faces").clear
+ end
+
+ after :all do
+ Puppet::Interface::FaceCollection.instance_variable_set("@faces", @faces)
+ end
+
+ describe "#[]" do
+ it "should fail when no version is requested" do
+ expect { subject[:huzzah] }.should raise_error ArgumentError
+ end
+
+ it "should raise an exception when the requested version is unavailable" do
+ expect { subject[:huzzah, '17.0.0'] }.should raise_error, Puppet::Error
+ end
+
+ it "should raise an exception when the requested face doesn't exist" do
+ expect { subject[:burrble_toot, :current] }.should raise_error, Puppet::Error
+ end
+ end
+
+ describe "#define" do
+ it "should register the face" do
+ face = subject.define(:face_test_register, '0.0.1')
+ face.should == subject[:face_test_register, '0.0.1']
+ end
+
+ it "should load actions" do
+ subject.any_instance.expects(:load_actions)
+ subject.define(:face_test_load_actions, '0.0.1')
+ end
+
+ it "should require a version number" do
+ expect { subject.define(:no_version) }.to raise_error ArgumentError
+ end
+
+ it "should support summary builder and accessor methods" do
+ subject.new(:foo, '1.0.0').should respond_to(:summary).with(0).arguments
+ subject.new(:foo, '1.0.0').should respond_to(:summary=).with(1).arguments
+ end
+
+ it "should set the summary text" do
+ text = "hello, freddy, my little pal"
+ subject.define(:face_test_summary, '1.0.0') do
+ summary text
+ end
+ subject[:face_test_summary, '1.0.0'].summary.should == text
+ end
+
+ it "should support mutating the summary" do
+ text = "hello, freddy, my little pal"
+ subject.define(:face_test_summary, '1.0.0') do
+ summary text
+ end
+ subject[:face_test_summary, '1.0.0'].summary.should == text
+ subject[:face_test_summary, '1.0.0'].summary = text + text
+ subject[:face_test_summary, '1.0.0'].summary.should == text + text
+ end
+ end
+
+ describe "#initialize" do
+ it "should require a version number" do
+ expect { subject.new(:no_version) }.to raise_error ArgumentError
+ end
+
+ it "should require a valid version number" do
+ expect { subject.new(:bad_version, 'Rasins') }.
+ should raise_error ArgumentError
+ end
+
+ it "should instance-eval any provided block" do
+ face = subject.new(:face_test_block, '0.0.1') do
+ action(:something) do
+ when_invoked { "foo" }
+ end
+ end
+
+ face.something.should == "foo"
+ end
+ end
+
+ it "should have a name" do
+ subject.new(:me, '0.0.1').name.should == :me
+ end
+
+ it "should stringify with its own name" do
+ subject.new(:me, '0.0.1').to_s.should =~ /\bme\b/
+ end
+
+ it "should allow overriding of the default format" do
+ face = subject.new(:me, '0.0.1')
+ face.set_default_format :foo
+ face.default_format.should == :foo
+ end
+
+ it "should default to :pson for its format" do
+ subject.new(:me, '0.0.1').default_format.should == :pson
+ end
+
+ # Why?
+ it "should create a class-level autoloader" do
+ subject.autoloader.should be_instance_of(Puppet::Util::Autoload)
+ end
+
+ it "should try to require faces that are not known" do
+ pending "mocking require causes random stack overflow"
+ subject::FaceCollection.expects(:require).with "puppet/face/foo"
+ subject[:foo, '0.0.1']
+ end
+
+ it "should be able to load all actions in all search paths"
+
+
+ it_should_behave_like "things that declare options" do
+ def add_options_to(&block)
+ subject.new(:with_options, '0.0.1', &block)
+ end
+ end
+
+ describe "with face-level options" do
+ it "should not return any action-level options" do
+ face = subject.new(:with_options, '0.0.1') do
+ option "--foo"
+ option "--bar"
+ action :baz do
+ option "--quux"
+ end
+ end
+ face.options.should =~ [:foo, :bar]
+ end
+
+ it "should fail when a face option duplicates an action option" do
+ expect {
+ subject.new(:action_level_options, '0.0.1') do
+ action :bar do option "--foo" end
+ option "--foo"
+ end
+ }.should raise_error ArgumentError, /Option foo conflicts with existing option foo on/i
+ end
+
+ it "should work when two actions have the same option" do
+ face = subject.new(:with_options, '0.0.1') do
+ action :foo do option "--quux" end
+ action :bar do option "--quux" end
+ end
+
+ face.get_action(:foo).options.should =~ [:quux]
+ face.get_action(:bar).options.should =~ [:quux]
+ end
+ end
+
+ describe "with inherited options" do
+ let :parent do
+ parent = Class.new(subject)
+ parent.option("--inherited")
+ parent.action(:parent_action) do end
+ parent
+ end
+
+ let :face do
+ face = parent.new(:example, '0.2.1')
+ face.option("--local")
+ face.action(:face_action) do end
+ face
+ end
+
+ describe "#options" do
+ it "should list inherited options" do
+ face.options.should =~ [:inherited, :local]
+ end
+
+ it "should see all options on face actions" do
+ face.get_action(:face_action).options.should =~ [:inherited, :local]
+ end
+
+ it "should see all options on inherited actions accessed on the subclass" do
+ face.get_action(:parent_action).options.should =~ [:inherited, :local]
+ end
+
+ it "should not see subclass actions on the parent class" do
+ parent.options.should =~ [:inherited]
+ end
+
+ it "should not see subclass actions on actions accessed on the parent class" do
+ parent.get_action(:parent_action).options.should =~ [:inherited]
+ end
+ end
+
+ describe "#get_option" do
+ it "should return an inherited option object" do
+ face.get_option(:inherited).should be_an_instance_of subject::Option
+ end
+ end
+ end
+end
diff --git a/spec/unit/module_spec.rb b/spec/unit/module_spec.rb
index f3120e16b..8d38657f9 100755
--- a/spec/unit/module_spec.rb
+++ b/spec/unit/module_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet_spec/files'
describe Puppet::Module do
diff --git a/spec/unit/network/authconfig_spec.rb b/spec/unit/network/authconfig_spec.rb
index 9d69e99ac..c47b2e0c5 100755
--- a/spec/unit/network/authconfig_spec.rb
+++ b/spec/unit/network/authconfig_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/authconfig'
diff --git a/spec/unit/network/authstore_spec.rb b/spec/unit/network/authstore_spec.rb
index d477ee301..d62c8abaa 100644..100755
--- a/spec/unit/network/authstore_spec.rb
+++ b/spec/unit/network/authstore_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/authconfig'
diff --git a/spec/unit/network/client_spec.rb b/spec/unit/network/client_spec.rb
index 820f10f12..102a053c0 100755
--- a/spec/unit/network/client_spec.rb
+++ b/spec/unit/network/client_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-24.
# Copyright (c) 2008. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/network/client'
diff --git a/spec/unit/network/format_handler_spec.rb b/spec/unit/network/format_handler_spec.rb
index 556fada80..8b535c3ab 100755
--- a/spec/unit/network/format_handler_spec.rb
+++ b/spec/unit/network/format_handler_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/format_handler'
diff --git a/spec/unit/network/format_spec.rb b/spec/unit/network/format_spec.rb
index 658729e4c..f59593479 100755
--- a/spec/unit/network/format_spec.rb
+++ b/spec/unit/network/format_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/format'
diff --git a/spec/unit/network/formats_spec.rb b/spec/unit/network/formats_spec.rb
index 30e88c578..72d355192 100755
--- a/spec/unit/network/formats_spec.rb
+++ b/spec/unit/network/formats_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/formats'
diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb
index 014b82e69..52c4a71f5 100644..100755
--- a/spec/unit/network/handler/fileserver_spec.rb
+++ b/spec/unit/network/handler/fileserver_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/handler/fileserver'
diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb
index 257eec5de..bd95071c1 100644..100755
--- a/spec/unit/network/http/api/v1_spec.rb
+++ b/spec/unit/network/http/api/v1_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/http/api/v1'
@@ -68,6 +67,10 @@ describe Puppet::Network::HTTP::API::V1 do
@tester.uri2indirection("GET", "/env/foo/bar", {})[1].should == :find
end
+ it "should choose 'find' as the indirection method if the http method is a POST and the indirection name is singular" do
+ @tester.uri2indirection("POST", "/env/foo/bar", {})[1].should == :find
+ end
+
it "should choose 'head' as the indirection method if the http method is a HEAD and the indirection name is singular" do
@tester.uri2indirection("HEAD", "/env/foo/bar", {})[1].should == :head
end
@@ -164,4 +167,26 @@ describe Puppet::Network::HTTP::API::V1 do
end
end
+ describe "when converting a request into a URI with body" do
+ before :each do
+ @request = Puppet::Indirector::Request.new(:foo, :find, "with spaces", :foo => :bar, :environment => "myenv")
+ end
+
+ it "should use the environment as the first field of the URI" do
+ @tester.request_to_uri_and_body(@request).first.split("/")[1].should == "myenv"
+ end
+
+ it "should use the indirection as the second field of the URI" do
+ @tester.request_to_uri_and_body(@request).first.split("/")[2].should == "foo"
+ end
+
+ it "should use the escaped key as the remainder of the URI" do
+ escaped = URI.escape("with spaces")
+ @tester.request_to_uri_and_body(@request).first.split("/")[3].sub(/\?.+/, '').should == escaped
+ end
+
+ it "should return the URI and body separately" do
+ @tester.request_to_uri_and_body(@request).should == ["/myenv/foo/with%20spaces", "foo=bar"]
+ end
+ end
end
diff --git a/spec/unit/network/http/compression_spec.rb b/spec/unit/network/http/compression_spec.rb
index 85c62f358..5c919c6c5 100755
--- a/spec/unit/network/http/compression_spec.rb
+++ b/spec/unit/network/http/compression_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "http compression" do
diff --git a/spec/unit/network/http/handler_spec.rb b/spec/unit/network/http/handler_spec.rb
index 97d17fcf8..83969c504 100755
--- a/spec/unit/network/http/handler_spec.rb
+++ b/spec/unit/network/http/handler_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/http/handler'
require 'puppet/network/rest_authorization'
diff --git a/spec/unit/network/http/mongrel/rest_spec.rb b/spec/unit/network/http/mongrel/rest_spec.rb
index 086fec522..3e454cf8f 100755
--- a/spec/unit/network/http/mongrel/rest_spec.rb
+++ b/spec/unit/network/http/mongrel/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/http'
diff --git a/spec/unit/network/http/mongrel_spec.rb b/spec/unit/network/http/mongrel_spec.rb
index 5a67a3fae..56d0afbed 100755
--- a/spec/unit/network/http/mongrel_spec.rb
+++ b/spec/unit/network/http/mongrel_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Rick Bradley on 2007-10-15.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/network/http'
describe "Puppet::Network::HTTP::Mongrel", "after initializing", :if => Puppet.features.mongrel? do
diff --git a/spec/unit/network/http/rack/rest_spec.rb b/spec/unit/network/http/rack/rest_spec.rb
index dd49fa057..8a5666f56 100755
--- a/spec/unit/network/http/rack/rest_spec.rb
+++ b/spec/unit/network/http/rack/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/http/rack' if Puppet.features.rack?
require 'puppet/network/http/rack/rest'
diff --git a/spec/unit/network/http/rack/xmlrpc_spec.rb b/spec/unit/network/http/rack/xmlrpc_spec.rb
index e8ae47bf7..9173438a6 100755
--- a/spec/unit/network/http/rack/xmlrpc_spec.rb
+++ b/spec/unit/network/http/rack/xmlrpc_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/handler'
require 'puppet/network/http/rack' if Puppet.features.rack?
require 'puppet/network/http/rack/xmlrpc' if Puppet.features.rack?
diff --git a/spec/unit/network/http/rack_spec.rb b/spec/unit/network/http/rack_spec.rb
index 75d3fdb90..9e1ee3d1e 100755
--- a/spec/unit/network/http/rack_spec.rb
+++ b/spec/unit/network/http/rack_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/handler'
require 'puppet/network/http/rack' if Puppet.features.rack?
diff --git a/spec/unit/network/http/webrick/rest_spec.rb b/spec/unit/network/http/webrick/rest_spec.rb
index b1491e32e..267ddcc72 100755
--- a/spec/unit/network/http/webrick/rest_spec.rb
+++ b/spec/unit/network/http/webrick/rest_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/http'
require 'webrick'
require 'puppet/network/http/webrick/rest'
diff --git a/spec/unit/network/http/webrick_spec.rb b/spec/unit/network/http/webrick_spec.rb
index b27a941ea..be74a1052 100755
--- a/spec/unit/network/http/webrick_spec.rb
+++ b/spec/unit/network/http/webrick_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Rick Bradley on 2007-10-15.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/network/handler'
require 'puppet/network/http'
require 'puppet/network/http/webrick'
diff --git a/spec/unit/network/http_pool_spec.rb b/spec/unit/network/http_pool_spec.rb
index 2cd96cea4..c5d3e0470 100755
--- a/spec/unit/network/http_pool_spec.rb
+++ b/spec/unit/network/http_pool_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-11-26.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/network/http_pool'
describe Puppet::Network::HttpPool do
diff --git a/spec/unit/network/http_spec.rb b/spec/unit/network/http_spec.rb
index 8422e2113..550c15bf7 100755
--- a/spec/unit/network/http_spec.rb
+++ b/spec/unit/network/http_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Rick Bradley on 2007-10-03.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/network/http'
diff --git a/spec/unit/network/rest_authconfig_spec.rb b/spec/unit/network/rest_authconfig_spec.rb
index e0bcb5af0..499a14b78 100755
--- a/spec/unit/network/rest_authconfig_spec.rb
+++ b/spec/unit/network/rest_authconfig_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/rest_authconfig'
diff --git a/spec/unit/network/rights_spec.rb b/spec/unit/network/rights_spec.rb
index 8ae03c56d..b709f10fa 100755
--- a/spec/unit/network/rights_spec.rb
+++ b/spec/unit/network/rights_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/network/rights'
diff --git a/spec/unit/network/server_spec.rb b/spec/unit/network/server_spec.rb
index 2a63cd4ec..912275a20 100755
--- a/spec/unit/network/server_spec.rb
+++ b/spec/unit/network/server_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Rick Bradley on 2007-10-03.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/network/server'
require 'puppet/network/handler'
diff --git a/spec/unit/network/xmlrpc/client_spec.rb b/spec/unit/network/xmlrpc/client_spec.rb
index 7498ca4cf..b9be0a906 100755
--- a/spec/unit/network/xmlrpc/client_spec.rb
+++ b/spec/unit/network/xmlrpc/client_spec.rb
@@ -1,7 +1,7 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
require 'puppet/network/client'
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
describe Puppet::Network::XMLRPCClient do
describe "when performing the rpc call" do
diff --git a/spec/unit/node/environment_spec.rb b/spec/unit/node/environment_spec.rb
index d34bdb000..d1badfa3a 100755
--- a/spec/unit/node/environment_spec.rb
+++ b/spec/unit/node/environment_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/node/environment'
require 'puppet/util/execution'
diff --git a/spec/unit/node/facts_spec.rb b/spec/unit/node/facts_spec.rb
index 797009ae4..a130ae3f8 100755
--- a/spec/unit/node/facts_spec.rb
+++ b/spec/unit/node/facts_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/node/facts'
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index ec1b65ee1..7d813ba30 100755
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Node do
describe "when managing its environment" do
diff --git a/spec/unit/other/selinux_spec.rb b/spec/unit/other/selinux_spec.rb
index 7f908885f..216feaf1f 100644..100755
--- a/spec/unit/other/selinux_spec.rb
+++ b/spec/unit/other/selinux_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/type/selboolean'
require 'puppet/type/selmodule'
diff --git a/spec/unit/other/transbucket_spec.rb b/spec/unit/other/transbucket_spec.rb
index 6bc257897..b95a4abca 100755
--- a/spec/unit/other/transbucket_spec.rb
+++ b/spec/unit/other/transbucket_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::TransBucket do
before do
diff --git a/spec/unit/other/transobject_spec.rb b/spec/unit/other/transobject_spec.rb
index c2652a386..4715e2fa1 100755
--- a/spec/unit/other/transobject_spec.rb
+++ b/spec/unit/other/transobject_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/transportable'
diff --git a/spec/unit/parameter/path_spec.rb b/spec/unit/parameter/path_spec.rb
index 08a26de33..d113a1581 100644..100755
--- a/spec/unit/parameter/path_spec.rb
+++ b/spec/unit/parameter/path_spec.rb
@@ -1,5 +1,5 @@
-#!/usr/bin/env ruby
-require File.expand_path(File.join(File.dirname(__FILE__), '../../spec_helper'))
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parameter/path'
diff --git a/spec/unit/parameter/value_collection_spec.rb b/spec/unit/parameter/value_collection_spec.rb
index 99e4302bc..af70160c1 100755
--- a/spec/unit/parameter/value_collection_spec.rb
+++ b/spec/unit/parameter/value_collection_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parameter'
diff --git a/spec/unit/parameter/value_spec.rb b/spec/unit/parameter/value_spec.rb
index cb44770b4..f3414e4e0 100755
--- a/spec/unit/parameter/value_spec.rb
+++ b/spec/unit/parameter/value_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parameter'
diff --git a/spec/unit/parameter_spec.rb b/spec/unit/parameter_spec.rb
index c9ef32faf..04556c013 100755
--- a/spec/unit/parameter_spec.rb
+++ b/spec/unit/parameter_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parameter'
diff --git a/spec/unit/parser/ast/arithmetic_operator_spec.rb b/spec/unit/parser/ast/arithmetic_operator_spec.rb
index 381c5c629..144ebd78c 100755
--- a/spec/unit/parser/ast/arithmetic_operator_spec.rb
+++ b/spec/unit/parser/ast/arithmetic_operator_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::ArithmeticOperator do
@@ -60,14 +59,4 @@ describe Puppet::Parser::AST::ArithmeticOperator do
operator.evaluate(@scope).should == 4.33
end
- it "should work for variables too" do
- @scope.expects(:lookupvar).with("one", false).returns(1)
- @scope.expects(:lookupvar).with("two", false).returns(2)
- one = ast::Variable.new( :value => "one" )
- two = ast::Variable.new( :value => "two" )
-
- operator = ast::ArithmeticOperator.new :lval => one, :operator => "+", :rval => two
- operator.evaluate(@scope).should == 3
- end
-
end
diff --git a/spec/unit/parser/ast/astarray_spec.rb b/spec/unit/parser/ast/astarray_spec.rb
index 01082b3f0..a3f56052a 100755
--- a/spec/unit/parser/ast/astarray_spec.rb
+++ b/spec/unit/parser/ast/astarray_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::ASTArray do
before :each do
diff --git a/spec/unit/parser/ast/asthash_spec.rb b/spec/unit/parser/ast/asthash_spec.rb
index 83f604545..d7fbbfae9 100644..100755
--- a/spec/unit/parser/ast/asthash_spec.rb
+++ b/spec/unit/parser/ast/asthash_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::ASTHash do
before :each do
diff --git a/spec/unit/parser/ast/boolean_operator_spec.rb b/spec/unit/parser/ast/boolean_operator_spec.rb
index 529946694..287f466a7 100755
--- a/spec/unit/parser/ast/boolean_operator_spec.rb
+++ b/spec/unit/parser/ast/boolean_operator_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::BooleanOperator do
diff --git a/spec/unit/parser/ast/casestatement_spec.rb b/spec/unit/parser/ast/casestatement_spec.rb
index bce3ad801..e21190706 100755
--- a/spec/unit/parser/ast/casestatement_spec.rb
+++ b/spec/unit/parser/ast/casestatement_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::CaseStatement do
before :each do
diff --git a/spec/unit/parser/ast/collection_spec.rb b/spec/unit/parser/ast/collection_spec.rb
index 99abc998d..78094e68d 100755
--- a/spec/unit/parser/ast/collection_spec.rb
+++ b/spec/unit/parser/ast/collection_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Collection do
before :each do
diff --git a/spec/unit/parser/ast/collexpr_spec.rb b/spec/unit/parser/ast/collexpr_spec.rb
index 04ce69cd3..454e7481b 100755
--- a/spec/unit/parser/ast/collexpr_spec.rb
+++ b/spec/unit/parser/ast/collexpr_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::CollExpr do
diff --git a/spec/unit/parser/ast/comparison_operator_spec.rb b/spec/unit/parser/ast/comparison_operator_spec.rb
index 03c9069cb..96f4562e9 100755
--- a/spec/unit/parser/ast/comparison_operator_spec.rb
+++ b/spec/unit/parser/ast/comparison_operator_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::ComparisonOperator do
before :each do
@@ -95,8 +94,8 @@ describe Puppet::Parser::AST::ComparisonOperator do
one = Puppet::Parser::AST::Variable.new( :value => "one" )
two = Puppet::Parser::AST::Variable.new( :value => "two" )
- @scope.expects(:lookupvar).with("one", false).returns(1)
- @scope.expects(:lookupvar).with("two", false).returns(2)
+ one.expects(:safeevaluate).with(@scope).returns(1)
+ two.expects(:safeevaluate).with(@scope).returns(2)
operator = Puppet::Parser::AST::ComparisonOperator.new :lval => one, :operator => "<", :rval => two
operator.evaluate(@scope).should == true
diff --git a/spec/unit/parser/ast/definition_spec.rb b/spec/unit/parser/ast/definition_spec.rb
index e7f55d258..8b2f7f26f 100644..100755
--- a/spec/unit/parser/ast/definition_spec.rb
+++ b/spec/unit/parser/ast/definition_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Definition do
it "should make its context available through an accessor" do
diff --git a/spec/unit/parser/ast/function_spec.rb b/spec/unit/parser/ast/function_spec.rb
index cd4b0f94e..c52e806e9 100644..100755
--- a/spec/unit/parser/ast/function_spec.rb
+++ b/spec/unit/parser/ast/function_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Function do
before :each do
diff --git a/spec/unit/parser/ast/hostclass_spec.rb b/spec/unit/parser/ast/hostclass_spec.rb
index 390490788..ee154fac8 100644..100755
--- a/spec/unit/parser/ast/hostclass_spec.rb
+++ b/spec/unit/parser/ast/hostclass_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Hostclass do
def ast
diff --git a/spec/unit/parser/ast/ifstatement_spec.rb b/spec/unit/parser/ast/ifstatement_spec.rb
index 6a2fed22c..4b6e0b8e5 100755
--- a/spec/unit/parser/ast/ifstatement_spec.rb
+++ b/spec/unit/parser/ast/ifstatement_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::IfStatement do
before :each do
diff --git a/spec/unit/parser/ast/in_operator_spec.rb b/spec/unit/parser/ast/in_operator_spec.rb
index 08c01582e..b6b6fbb89 100644..100755
--- a/spec/unit/parser/ast/in_operator_spec.rb
+++ b/spec/unit/parser/ast/in_operator_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parser/ast/in_operator'
diff --git a/spec/unit/parser/ast/leaf_spec.rb b/spec/unit/parser/ast/leaf_spec.rb
index 2119a27a8..ff3fed5e9 100755
--- a/spec/unit/parser/ast/leaf_spec.rb
+++ b/spec/unit/parser/ast/leaf_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Leaf do
before :each do
@@ -107,7 +106,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
describe "when evaluating" do
it "should evaluate the variable part if necessary" do
- @scope.stubs(:lookupvar).with("a").returns(["b"])
+ @scope.stubs(:lookupvar).with { |name,options| name == 'a'}.returns(["b"])
variable = stub 'variable', :evaluate => "a"
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => variable, :key => 0 )
@@ -118,7 +117,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should evaluate the access key part if necessary" do
- @scope.stubs(:lookupvar).with("a").returns(["b"])
+ @scope.stubs(:lookupvar).with { |name,options| name == 'a'}.returns(["b"])
index = stub 'index', :evaluate => 0
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => index )
@@ -129,7 +128,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should be able to return an array member" do
- @scope.stubs(:lookupvar).with("a").returns(["val1", "val2", "val3"])
+ @scope.stubs(:lookupvar).with { |name,options| name == 'a'}.returns(["val1", "val2", "val3"])
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => 1 )
@@ -137,7 +136,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should be able to return an array member when index is a stringified number" do
- @scope.stubs(:lookupvar).with("a").returns(["val1", "val2", "val3"])
+ @scope.stubs(:lookupvar).with { |name,options| name == "a" }.returns(["val1", "val2", "val3"])
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "1" )
@@ -145,7 +144,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error when accessing an array with a key" do
- @scope.stubs(:lookupvar).with("a").returns(["val1", "val2", "val3"])
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns(["val1", "val2", "val3"])
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "get_me_the_second_element_please" )
@@ -153,7 +152,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should be able to return an hash value" do
- @scope.stubs(:lookupvar).with("a").returns({ "key1" => "val1", "key2" => "val2", "key3" => "val3" })
+ @scope.stubs(:lookupvar).with { |name,options| name == 'a'}.returns({ "key1" => "val1", "key2" => "val2", "key3" => "val3" })
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key2" )
@@ -161,7 +160,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should be able to return an hash value with a numerical key" do
- @scope.stubs(:lookupvar).with("a").returns({ "key1" => "val1", "key2" => "val2", "45" => "45", "key3" => "val3" })
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns({ "key1" => "val1", "key2" => "val2", "45" => "45", "key3" => "val3" })
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "45" )
@@ -169,7 +168,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error if the variable lookup didn't return an hash or an array" do
- @scope.stubs(:lookupvar).with("a").returns("I'm a string")
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns("I'm a string")
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key2" )
@@ -177,7 +176,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error if the variable wasn't in the scope" do
- @scope.stubs(:lookupvar).with("a").returns(nil)
+ @scope.stubs(:lookupvar).with { |name,options| name == 'a'}.returns(nil)
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key2" )
@@ -190,7 +189,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should work with recursive hash access" do
- @scope.stubs(:lookupvar).with("a").returns({ "key" => { "subkey" => "b" }})
+ @scope.stubs(:lookupvar).with { |name,options| name == 'a'}.returns({ "key" => { "subkey" => "b" }})
access1 = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key")
access2 = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => access1, :key => "subkey")
@@ -199,7 +198,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should work with interleaved array and hash access" do
- @scope.stubs(:lookupvar).with("a").returns({ "key" => [ "a" , "b" ]})
+ @scope.stubs(:lookupvar).with { |name,options| name == 'a'}.returns({ "key" => [ "a" , "b" ]})
access1 = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key")
access2 = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => access1, :key => 1)
@@ -220,7 +219,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error when assigning an array element with a key" do
- @scope.stubs(:lookupvar).with("a").returns([])
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns([])
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "get_me_the_second_element_please" )
@@ -238,7 +237,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error when trying to overwrite an hash value" do
- @scope.stubs(:lookupvar).with("a").returns({ "key" => [ "a" , "b" ]})
+ @scope.stubs(:lookupvar).with { |name,options| name == "a" }.returns({ "key" => [ "a" , "b" ]})
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key")
lambda { access.assign(@scope, "test") }.should raise_error
@@ -332,16 +331,21 @@ end
describe Puppet::Parser::AST::Variable do
before :each do
@scope = stub 'scope'
- @var = Puppet::Parser::AST::Variable.new(:value => "myvar")
+ @var = Puppet::Parser::AST::Variable.new(:value => "myvar", :file => 'my.pp', :line => 222)
end
it "should lookup the variable in scope" do
- @scope.expects(:lookupvar).with("myvar", false).returns(:myvalue)
+ @scope.expects(:lookupvar).with { |name,options| name == "myvar" }.returns(:myvalue)
+ @var.safeevaluate(@scope).should == :myvalue
+ end
+
+ it "should pass the source location to lookupvar" do
+ @scope.expects(:lookupvar).with { |name,options| name == "myvar" and options[:file] == 'my.pp' and options[:line] == 222 }.returns(:myvalue)
@var.safeevaluate(@scope).should == :myvalue
end
it "should return undef if the variable wasn't set" do
- @scope.expects(:lookupvar).with("myvar", false).returns(:undefined)
+ @scope.expects(:lookupvar).with { |name,options| name == "myvar" }.returns(:undefined)
@var.safeevaluate(@scope).should == :undef
end
diff --git a/spec/unit/parser/ast/match_operator_spec.rb b/spec/unit/parser/ast/match_operator_spec.rb
index f2a68b676..0f9235aeb 100755
--- a/spec/unit/parser/ast/match_operator_spec.rb
+++ b/spec/unit/parser/ast/match_operator_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::MatchOperator do
before :each do
diff --git a/spec/unit/parser/ast/minus_spec.rb b/spec/unit/parser/ast/minus_spec.rb
index 339087e80..8ebd14e80 100755
--- a/spec/unit/parser/ast/minus_spec.rb
+++ b/spec/unit/parser/ast/minus_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Minus do
before :each do
diff --git a/spec/unit/parser/ast/node_spec.rb b/spec/unit/parser/ast/node_spec.rb
index c4e20ca67..c2e187184 100644..100755
--- a/spec/unit/parser/ast/node_spec.rb
+++ b/spec/unit/parser/ast/node_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Node do
describe "when instantiated" do
diff --git a/spec/unit/parser/ast/nop_spec.rb b/spec/unit/parser/ast/nop_spec.rb
index 3fa2fc0ee..81302fa55 100755
--- a/spec/unit/parser/ast/nop_spec.rb
+++ b/spec/unit/parser/ast/nop_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Nop do
diff --git a/spec/unit/parser/ast/not_spec.rb b/spec/unit/parser/ast/not_spec.rb
index 31a425132..6569af699 100755
--- a/spec/unit/parser/ast/not_spec.rb
+++ b/spec/unit/parser/ast/not_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Not do
before :each do
diff --git a/spec/unit/parser/ast/relationship_spec.rb b/spec/unit/parser/ast/relationship_spec.rb
index d8bc3a535..441ac45b1 100644..100755
--- a/spec/unit/parser/ast/relationship_spec.rb
+++ b/spec/unit/parser/ast/relationship_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Relationship do
before do
diff --git a/spec/unit/parser/ast/resource_defaults_spec.rb b/spec/unit/parser/ast/resource_defaults_spec.rb
index 36eb8df5f..8164828e1 100755
--- a/spec/unit/parser/ast/resource_defaults_spec.rb
+++ b/spec/unit/parser/ast/resource_defaults_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::ResourceDefaults do
diff --git a/spec/unit/parser/ast/resource_override_spec.rb b/spec/unit/parser/ast/resource_override_spec.rb
index 7ca3a7e8c..458d9a4bf 100755
--- a/spec/unit/parser/ast/resource_override_spec.rb
+++ b/spec/unit/parser/ast/resource_override_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::ResourceOverride do
diff --git a/spec/unit/parser/ast/resource_reference_spec.rb b/spec/unit/parser/ast/resource_reference_spec.rb
index 492c25490..627754dd1 100755
--- a/spec/unit/parser/ast/resource_reference_spec.rb
+++ b/spec/unit/parser/ast/resource_reference_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::ResourceReference do
diff --git a/spec/unit/parser/ast/resource_spec.rb b/spec/unit/parser/ast/resource_spec.rb
index b00fee587..68ad9c229 100755
--- a/spec/unit/parser/ast/resource_spec.rb
+++ b/spec/unit/parser/ast/resource_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Resource do
ast = Puppet::Parser::AST
diff --git a/spec/unit/parser/ast/selector_spec.rb b/spec/unit/parser/ast/selector_spec.rb
index 4c13aa7ba..1bf5f6757 100755
--- a/spec/unit/parser/ast/selector_spec.rb
+++ b/spec/unit/parser/ast/selector_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::Selector do
before :each do
diff --git a/spec/unit/parser/ast/vardef_spec.rb b/spec/unit/parser/ast/vardef_spec.rb
index 9c8b77905..7dd2b31e7 100755
--- a/spec/unit/parser/ast/vardef_spec.rb
+++ b/spec/unit/parser/ast/vardef_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::AST::VarDef do
before :each do
@@ -16,8 +15,7 @@ describe Puppet::Parser::AST::VarDef do
name.expects(:safeevaluate).with(@scope)
value.expects(:safeevaluate).with(@scope)
- vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil,
- :line => nil
+ vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil, :line => nil
vardef.evaluate(@scope)
end
@@ -27,8 +25,7 @@ describe Puppet::Parser::AST::VarDef do
@scope.expects(:setvar).with { |name,value,options| options[:append] == nil }
- vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil,
- :line => nil
+ vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil, :line => nil
vardef.evaluate(@scope)
end
@@ -38,8 +35,17 @@ describe Puppet::Parser::AST::VarDef do
@scope.expects(:setvar).with { |name,value,options| options[:append] == true }
- vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil,
- :line => nil, :append => true
+ vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => nil, :line => nil, :append => true
+ vardef.evaluate(@scope)
+ end
+
+ it "should call pass the source location to setvar" do
+ name = stub 'name', :safeevaluate => "var"
+ value = stub 'value', :safeevaluate => "1"
+
+ @scope.expects(:setvar).with { |name,value,options| options[:file] == 'setvar.pp' and options[:line] == 917 }
+
+ vardef = Puppet::Parser::AST::VarDef.new :name => name, :value => value, :file => 'setvar.pp', :line => 917
vardef.evaluate(@scope)
end
diff --git a/spec/unit/parser/ast_spec.rb b/spec/unit/parser/ast_spec.rb
index cdfb51869..4d4871219 100644..100755
--- a/spec/unit/parser/ast_spec.rb
+++ b/spec/unit/parser/ast_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parser/ast'
diff --git a/spec/unit/parser/collector_spec.rb b/spec/unit/parser/collector_spec.rb
index 100a04daf..01918d2a0 100755
--- a/spec/unit/parser/collector_spec.rb
+++ b/spec/unit/parser/collector_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/rails'
require 'puppet/parser/collector'
diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb
index e4b18e14b..ced760b76 100755
--- a/spec/unit/parser/compiler_spec.rb
+++ b/spec/unit/parser/compiler_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
class CompilerTestResource
attr_accessor :builtin, :virtual, :evaluated, :type, :title
@@ -131,10 +130,6 @@ describe Puppet::Parser::Compiler do
@compiler.newscope(@compiler.topscope).should be_instance_of(Puppet::Parser::Scope)
end
- it "should correctly set the level of newly created scopes" do
- @compiler.newscope(@compiler.topscope, :level => 5).level.should == 5
- end
-
it "should set the parent scope of the new scope to be the passed-in parent" do
scope = mock 'scope'
newscope = @compiler.newscope(scope)
diff --git a/spec/unit/parser/files_spec.rb b/spec/unit/parser/files_spec.rb
index 525c83697..04777f0ec 100644..100755
--- a/spec/unit/parser/files_spec.rb
+++ b/spec/unit/parser/files_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parser/files'
diff --git a/spec/unit/parser/functions/create_resources_spec.rb b/spec/unit/parser/functions/create_resources_spec.rb
index 366fb536c..88a67e369 100755
--- a/spec/unit/parser/functions/create_resources_spec.rb
+++ b/spec/unit/parser/functions/create_resources_spec.rb
@@ -1,5 +1,5 @@
require 'puppet'
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require 'spec_helper'
describe 'function for dynamically creating resources' do
diff --git a/spec/unit/parser/functions/defined_spec.rb b/spec/unit/parser/functions/defined_spec.rb
index 0113c3233..0651864fb 100755
--- a/spec/unit/parser/functions/defined_spec.rb
+++ b/spec/unit/parser/functions/defined_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the 'defined' function" do
before :all do
diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb
index 46cd3cc27..f68daaf3f 100755
--- a/spec/unit/parser/functions/extlookup_spec.rb
+++ b/spec/unit/parser/functions/extlookup_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'tempfile'
describe "the extlookup function" do
@@ -65,7 +64,7 @@ describe "the extlookup function" do
describe "should look in $extlookup_datadir for data files listed by $extlookup_precedence" do
before do
- @scope.stubs(:lookupvar).with('extlookup_datadir').returns("/tmp")
+ @scope.stubs(:lookupvar).with('::extlookup_datadir').returns("/tmp")
File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" }
File.open("/tmp/two.csv","w") do |two|
two.puts "key,value2"
@@ -74,21 +73,21 @@ describe "the extlookup function" do
end
it "when the key is in the first file" do
- @scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"])
+ @scope.stubs(:lookupvar).with('::extlookup_precedence').returns(["one","two"])
result = @scope.function_extlookup([ "key" ])
result.should == "value1"
end
it "when the key is in the second file" do
- @scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"])
+ @scope.stubs(:lookupvar).with('::extlookup_precedence').returns(["one","two"])
result = @scope.function_extlookup([ "key2" ])
result.should == "value_two"
end
it "should not modify extlookup_precedence data" do
variable = '%{fqdn}'
- @scope.stubs(:lookupvar).with('extlookup_precedence').returns([variable,"one"])
- @scope.stubs(:lookupvar).with('fqdn').returns('myfqdn')
+ @scope.stubs(:lookupvar).with('::extlookup_precedence').returns([variable,"one"])
+ @scope.stubs(:lookupvar).with('::fqdn').returns('myfqdn')
result = @scope.function_extlookup([ "key" ])
variable.should == '%{fqdn}'
end
diff --git a/spec/unit/parser/functions/fqdn_rand_spec.rb b/spec/unit/parser/functions/fqdn_rand_spec.rb
index be2e6fa76..90fc0ef41 100755
--- a/spec/unit/parser/functions/fqdn_rand_spec.rb
+++ b/spec/unit/parser/functions/fqdn_rand_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the fqdn_rand function" do
before :all do
@@ -16,49 +15,49 @@ describe "the fqdn_rand function" do
end
it "should handle 0 arguments" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([]) }.should_not raise_error(Puppet::ParseError)
end
it "should handle 1 argument'}" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3]) }.should_not raise_error(Puppet::ParseError)
end
(1..10).each { |n|
it "should handle #{n} additional arguments" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3,1,2,3,4,5,6,7,8,9,10][0..n]) }.should_not raise_error(Puppet::ParseError)
end
it "should handle #{n} additional string arguments" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3,%w{ 1 2 3 4 5 6 7 8 9 10}].flatten[0..n]) }.should_not raise_error(Puppet::ParseError)
end
}
it "should return a value less than max" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
@scope.function_fqdn_rand([3]).should satisfy {|n| n.to_i < 3 }
end
it "should return the same values on subsequent invocations for the same host" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1").twice
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
@scope.function_fqdn_rand([3,4]).should eql(@scope.function_fqdn_rand([3, 4]))
end
it "should return different sequences of value for different hosts" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val1 = @scope.function_fqdn_rand([10000000,4])
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.2")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.2")
val2 = @scope.function_fqdn_rand([10000000,4])
val1.should_not eql(val2)
end
it "should return different values for the same hosts with different seeds" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val1 = @scope.function_fqdn_rand([10000000,4])
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val2 = @scope.function_fqdn_rand([10000000,42])
val1.should_not eql(val2)
end
diff --git a/spec/unit/parser/functions/generate_spec.rb b/spec/unit/parser/functions/generate_spec.rb
index d25015b56..6c90ae531 100755
--- a/spec/unit/parser/functions/generate_spec.rb
+++ b/spec/unit/parser/functions/generate_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the generate function" do
before :all do
diff --git a/spec/unit/parser/functions/include_spec.rb b/spec/unit/parser/functions/include_spec.rb
index cfaadfbb6..15206cd7c 100755
--- a/spec/unit/parser/functions/include_spec.rb
+++ b/spec/unit/parser/functions/include_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the 'include' function" do
before :all do
diff --git a/spec/unit/parser/functions/inline_template_spec.rb b/spec/unit/parser/functions/inline_template_spec.rb
index 712c68c69..a9ac0c2d0 100755
--- a/spec/unit/parser/functions/inline_template_spec.rb
+++ b/spec/unit/parser/functions/inline_template_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the inline_template function" do
before :all do
diff --git a/spec/unit/parser/functions/realize_spec.rb b/spec/unit/parser/functions/realize_spec.rb
index 3106c42b6..159805cbd 100755
--- a/spec/unit/parser/functions/realize_spec.rb
+++ b/spec/unit/parser/functions/realize_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the realize function" do
before :all do
diff --git a/spec/unit/parser/functions/regsubst_spec.rb b/spec/unit/parser/functions/regsubst_spec.rb
index 1fb8e410c..4ed3bcf68 100755
--- a/spec/unit/parser/functions/regsubst_spec.rb
+++ b/spec/unit/parser/functions/regsubst_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the regsubst function" do
before :all do
diff --git a/spec/unit/parser/functions/require_spec.rb b/spec/unit/parser/functions/require_spec.rb
index edcbc4ae6..692b35305 100755
--- a/spec/unit/parser/functions/require_spec.rb
+++ b/spec/unit/parser/functions/require_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the require function" do
before :all do
diff --git a/spec/unit/parser/functions/shellquote_spec.rb b/spec/unit/parser/functions/shellquote_spec.rb
index 55302b97b..b100b4913 100755
--- a/spec/unit/parser/functions/shellquote_spec.rb
+++ b/spec/unit/parser/functions/shellquote_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the shellquote function" do
before :all do
diff --git a/spec/unit/parser/functions/split_spec.rb b/spec/unit/parser/functions/split_spec.rb
index b892a5c2a..18a21a0cf 100755
--- a/spec/unit/parser/functions/split_spec.rb
+++ b/spec/unit/parser/functions/split_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the split function" do
before :all do
diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb
index 69fbb5e97..bd4863f23 100755
--- a/spec/unit/parser/functions/sprintf_spec.rb
+++ b/spec/unit/parser/functions/sprintf_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the sprintf function" do
before :all do
diff --git a/spec/unit/parser/functions/tag_spec.rb b/spec/unit/parser/functions/tag_spec.rb
index b6bb45252..e8a07e1bb 100755
--- a/spec/unit/parser/functions/tag_spec.rb
+++ b/spec/unit/parser/functions/tag_spec.rb
@@ -1,6 +1,5 @@
-#! /usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the 'tag' function" do
before :all do
diff --git a/spec/unit/parser/functions/template_spec.rb b/spec/unit/parser/functions/template_spec.rb
index 7eaf3554d..e7ee974d3 100755
--- a/spec/unit/parser/functions/template_spec.rb
+++ b/spec/unit/parser/functions/template_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the template function" do
before :all do
diff --git a/spec/unit/parser/functions/versioncmp_spec.rb b/spec/unit/parser/functions/versioncmp_spec.rb
index ddc79cd85..6fc724c38 100755
--- a/spec/unit/parser/functions/versioncmp_spec.rb
+++ b/spec/unit/parser/functions/versioncmp_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "the versioncmp function" do
before :all do
diff --git a/spec/unit/parser/functions_spec.rb b/spec/unit/parser/functions_spec.rb
index 51e52faee..8240a184c 100644..100755
--- a/spec/unit/parser/functions_spec.rb
+++ b/spec/unit/parser/functions_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::Functions do
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index bc9e22e48..6cdb0553a 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parser/lexer'
diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb
index 01cdcb976..78adc30ee 100755
--- a/spec/unit/parser/parser_spec.rb
+++ b/spec/unit/parser/parser_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser do
diff --git a/spec/unit/parser/relationship_spec.rb b/spec/unit/parser/relationship_spec.rb
index 883a38d11..5a49831e1 100644..100755
--- a/spec/unit/parser/relationship_spec.rb
+++ b/spec/unit/parser/relationship_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parser/relationship'
diff --git a/spec/unit/parser/resource_spec.rb b/spec/unit/parser/resource_spec.rb
index 73c4412dd..b03c18e5f 100755
--- a/spec/unit/parser/resource_spec.rb
+++ b/spec/unit/parser/resource_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
# LAK: FIXME This is just new tests for resources; I have
# not moved all tests over yet.
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb
index 32a87f1f4..bf4d1e29e 100755
--- a/spec/unit/parser/scope_spec.rb
+++ b/spec/unit/parser/scope_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Parser::Scope do
before :each do
@@ -73,19 +72,19 @@ describe Puppet::Parser::Scope do
Puppet::Parser::Scope.new.singleton_class.ancestors.should be_include(mod)
end
- end
- describe "when looking up a variable" do
- it "should default to an empty string" do
- @scope.lookupvar("var").should == ""
+ it "should remember if it is dynamic" do
+ (!!Puppet::Parser::Scope.new(:dynamic => true).dynamic).should == true
end
- it "should return an string when asked for a string" do
- @scope.lookupvar("var", true).should == ""
+ it "should assume it is not dynamic" do
+ (!Puppet::Parser::Scope.new.dynamic).should == true
end
+ end
- it "should return ':undefined' for unset variables when asked not to return a string" do
- @scope.lookupvar("var", false).should == :undefined
+ describe "when looking up a variable" do
+ it "should return ':undefined' for unset variables" do
+ @scope.lookupvar("var").should == :undefined
end
it "should be able to look up values" do
@@ -151,32 +150,32 @@ describe Puppet::Parser::Scope do
@scope.lookupvar("other::deep::klass::var").should == "otherval"
end
- it "should return an empty string for qualified variables that cannot be found in other classes" do
+ it "should return ':undefined' for qualified variables that cannot be found in other classes" do
other_scope = create_class_scope("other::deep::klass")
- @scope.lookupvar("other::deep::klass::var").should == ""
+ @scope.lookupvar("other::deep::klass::var").should == :undefined
end
- it "should warn and return an empty string for qualified variables whose classes have not been evaluated" do
+ it "should warn and return ':undefined' for qualified variables whose classes have not been evaluated" do
klass = newclass("other::deep::klass")
@scope.expects(:warning)
- @scope.lookupvar("other::deep::klass::var").should == ""
+ @scope.lookupvar("other::deep::klass::var").should == :undefined
end
- it "should warn and return an empty string for qualified variables whose classes do not exist" do
+ it "should warn and return ':undefined' for qualified variables whose classes do not exist" do
@scope.expects(:warning)
- @scope.lookupvar("other::deep::klass::var").should == ""
+ @scope.lookupvar("other::deep::klass::var").should == :undefined
end
it "should return ':undefined' when asked for a non-string qualified variable from a class that does not exist" do
@scope.stubs(:warning)
- @scope.lookupvar("other::deep::klass::var", false).should == :undefined
+ @scope.lookupvar("other::deep::klass::var").should == :undefined
end
it "should return ':undefined' when asked for a non-string qualified variable from a class that has not been evaluated" do
@scope.stubs(:warning)
klass = newclass("other::deep::klass")
- @scope.lookupvar("other::deep::klass::var", false).should == :undefined
+ @scope.lookupvar("other::deep::klass::var").should == :undefined
end
end
end
@@ -291,7 +290,7 @@ describe Puppet::Parser::Scope do
@scope.unset_ephemeral_var
- @scope.lookupvar("1", false).should == :undefined
+ @scope.lookupvar("1").should == :undefined
end
it "should not remove classic variables when unset_ephemeral_var is called" do
@@ -301,7 +300,7 @@ describe Puppet::Parser::Scope do
@scope.unset_ephemeral_var
- @scope.lookupvar("myvar", false).should == :value1
+ @scope.lookupvar("myvar").should == :value1
end
it "should raise an error when setting it again" do
@@ -322,7 +321,7 @@ describe Puppet::Parser::Scope do
@scope.setvar("0", :earliest, :ephemeral => true)
@scope.new_ephemeral
@scope.setvar("0", :latest, :ephemeral => true)
- @scope.lookupvar("0", false).should == :latest
+ @scope.lookupvar("0").should == :latest
end
it "should be able to report the current level" do
@@ -353,7 +352,7 @@ describe Puppet::Parser::Scope do
@scope.setvar("1", :value1, :ephemeral => true)
@scope.new_ephemeral
@scope.setvar("0", :value2, :ephemeral => true)
- @scope.lookupvar("1", false).should == :value1
+ @scope.lookupvar("1").should == :value1
end
describe "when calling unset_ephemeral_var without a level" do
@@ -364,7 +363,7 @@ describe Puppet::Parser::Scope do
@scope.unset_ephemeral_var
- @scope.lookupvar("1", false).should == :undefined
+ @scope.lookupvar("1").should == :undefined
end
end
@@ -378,152 +377,9 @@ describe Puppet::Parser::Scope do
@scope.unset_ephemeral_var(2)
- @scope.lookupvar("1", false).should == :value2
- end
- end
- end
- end
-
- describe "when interpolating string" do
- (0..9).each do |n|
- it "should allow $#{n} to match" do
- @scope.setvar(n.to_s, "value", :ephemeral => true)
-
- @scope.strinterp("$#{n}").should == "value"
- end
- end
-
- (0..9).each do |n|
- it "should not allow $#{n} to match if not ephemeral" do
- @scope.setvar(n.to_s, "value", :ephemeral => false)
-
- @scope.strinterp("$#{n}").should_not == "value"
- end
- end
-
- it "should not allow $10 to match" do
- @scope.setvar("10", "value", :ephemeral => true)
-
- @scope.strinterp('==$10==').should_not == "==value=="
- end
-
- it "should not allow ${10} to match" do
- @scope.setvar("10", "value", :ephemeral => true)
-
- @scope.strinterp('==${10}==').should == "==value=="
- end
-
- describe "with qualified variables" do
- before do
- @scopes = {}
- klass = @scope.known_resource_types.add(Puppet::Resource::Type.new(:hostclass, ""))
- Puppet::Parser::Resource.new("class", :main, :scope => @scope, :source => mock('source')).evaluate
- @scopes[""] = @scope.class_scope(klass)
- @scopes[""].setvar("test", "value")
-
- %w{one one::two one::two::three}.each do |name|
- klass = @scope.known_resource_types.add(Puppet::Resource::Type.new(:hostclass, name))
- Puppet::Parser::Resource.new("class", name, :scope => @scope, :source => mock('source')).evaluate
- @scopes[name] = @scope.class_scope(klass)
- @scopes[name].setvar("test", "value-#{name.sub(/.+::/,'')}")
+ @scope.lookupvar("1").should == :value2
end
end
- {
- "===${one::two::three::test}===" => "===value-three===",
- "===$one::two::three::test===" => "===value-three===",
- "===${one::two::test}===" => "===value-two===",
- "===$one::two::test===" => "===value-two===",
- "===${one::test}===" => "===value-one===",
- "===$one::test===" => "===value-one===",
- "===${::test}===" => "===value===",
- "===$::test===" => "===value==="
- }.each do |input, output|
- it "should parse '#{input}' correctly" do
- @scope.strinterp(input).should == output
- end
- end
- end
-
- tests = {
- "===${test}===" => "===value===",
- "===${test} ${test} ${test}===" => "===value value value===",
- "===$test ${test} $test===" => "===value value value===",
- "===\\$test===" => "===$test===",
- '===\\$test string===' => "===$test string===",
- '===$test string===' => "===value string===",
- '===a testing $===' => "===a testing $===",
- '===a testing \$===' => "===a testing $===",
- "===an escaped \\\n carriage return===" => "===an escaped carriage return===",
- '\$' => "$",
- '\s' => "\s",
- '\t' => "\t",
- '\n' => "\n"
- }
-
- tests.each do |input, output|
- it "should parse '#{input}' correctly" do
- @scope.setvar("test", "value")
- @scope.strinterp(input).should == output
- end
- end
-
- # #523
- %w{d f h l w z}.each do |l|
- it "should parse '#{l}' when escaped" do
- string = "\\#{l}"
- @scope.strinterp(string).should == string
- end
- end
- end
-
- def test_strinterp
- # Make and evaluate our classes so the qualified lookups work
- parser = mkparser
- klass = parser.newclass("")
- scope = mkscope(:parser => parser)
- Puppet::Parser::Resource.new(:type => "class", :title => :main, :scope => scope, :source => mock('source')).evaluate
-
- assert_nothing_raised {
- scope.setvar("test","value")
- }
-
- scopes = {"" => scope}
-
- %w{one one::two one::two::three}.each do |name|
- klass = parser.newclass(name)
- Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
- scopes[name] = scope.class_scope(klass)
- scopes[name].setvar("test", "value-#{name.sub(/.+::/,'')}")
- end
-
- assert_equal("value", scope.lookupvar("::test"), "did not look up qualified value correctly")
- tests.each do |input, output|
- assert_nothing_raised("Failed to scan #{input.inspect}") do
- assert_equal(output, scope.strinterp(input), 'did not parserret %s correctly' % input.inspect)
- end
- end
-
- logs = []
- Puppet::Util::Log.close
- Puppet::Util::Log.newdestination(logs)
-
- # #523
- %w{d f h l w z}.each do |l|
- string = "\\#{l}"
- assert_nothing_raised do
-
- assert_equal(
- string, scope.strinterp(string),
-
- 'did not parserret %s correctly' % string)
- end
-
-
- assert(
- logs.detect { |m| m.message =~ /Unrecognised escape/ },
-
- "Did not get warning about escape sequence with #{string}")
- logs.clear
end
end
@@ -563,13 +419,13 @@ describe Puppet::Parser::Scope do
it "should be able to unset normal variables" do
@scope.setvar("foo", "bar")
@scope.unsetvar("foo")
- @scope.lookupvar("foo").should == ""
+ @scope.lookupvar("foo").should == :undefined
end
it "should be able to unset ephemeral variables" do
@scope.setvar("0", "bar", :ephemeral => true)
@scope.unsetvar("0")
- @scope.lookupvar("0").should == ""
+ @scope.lookupvar("0").should == :undefined
end
it "should not unset ephemeral variables in previous ephemeral scope" do
diff --git a/spec/unit/parser/templatewrapper_spec.rb b/spec/unit/parser/templatewrapper_spec.rb
index aab169348..600293bbf 100755
--- a/spec/unit/parser/templatewrapper_spec.rb
+++ b/spec/unit/parser/templatewrapper_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parser/templatewrapper'
describe Puppet::Parser::TemplateWrapper do
@@ -17,6 +16,12 @@ describe Puppet::Parser::TemplateWrapper do
@tw = Puppet::Parser::TemplateWrapper.new(@scope)
end
+ def mock_template(source=nil)
+ template_mock = mock("template", :result => "woot!")
+ ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
+ template_mock.expects(:filename=).with(source)
+ end
+
it "should create a new object TemplateWrapper from a scope" do
tw = Puppet::Parser::TemplateWrapper.new(@scope)
@@ -54,41 +59,38 @@ describe Puppet::Parser::TemplateWrapper do
end
it "should return the processed template contents with a call to result" do
- template_mock = mock("template", :result => "woot!")
+ mock_template("/tmp/fake_template")
File.expects(:read).with("/tmp/fake_template").returns("template contents")
- ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
@tw.file = @file
@tw.result.should eql("woot!")
end
it "should return the processed template contents with a call to result and a string" do
- template_mock = mock("template", :result => "woot!")
- ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
-
+ mock_template
@tw.result("template contents").should eql("woot!")
end
it "should return the contents of a variable if called via method_missing" do
- @scope.expects(:lookupvar).with("chicken", false).returns("is good")
+ @scope.expects(:lookupvar).with { |name,options| name == "chicken"}.returns("is good")
tw = Puppet::Parser::TemplateWrapper.new(@scope)
tw.chicken.should eql("is good")
end
it "should throw an exception if a variable is called via method_missing and it does not exist" do
- @scope.expects(:lookupvar).with("chicken", false).returns(:undefined)
+ @scope.expects(:lookupvar).with { |name,options| name == "chicken"}.returns(:undefined)
tw = Puppet::Parser::TemplateWrapper.new(@scope)
lambda { tw.chicken }.should raise_error(Puppet::ParseError)
end
it "should allow you to check whether a variable is defined with has_variable?" do
- @scope.expects(:lookupvar).with("chicken", false).returns("is good")
+ @scope.expects(:lookupvar).with { |name,options| name == "chicken"}.returns("is good")
tw = Puppet::Parser::TemplateWrapper.new(@scope)
tw.has_variable?("chicken").should eql(true)
end
it "should allow you to check whether a variable is not defined with has_variable?" do
- @scope.expects(:lookupvar).with("chicken", false).returns(:undefined)
+ @scope.expects(:lookupvar).with { |name,options| name == "chicken"}.returns(:undefined)
tw = Puppet::Parser::TemplateWrapper.new(@scope)
tw.has_variable?("chicken").should eql(false)
end
@@ -114,9 +116,7 @@ describe Puppet::Parser::TemplateWrapper do
end
it "should set all of the scope's variables as instance variables" do
- template_mock = mock("template", :result => "woot!")
- ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
-
+ mock_template
@scope.expects(:to_hash).returns("one" => "foo")
@tw.result("template contents")
@@ -124,8 +124,7 @@ describe Puppet::Parser::TemplateWrapper do
end
it "should not error out if one of the variables is a symbol" do
- template_mock = mock("template", :result => "woot!")
- ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
+ mock_template
@scope.expects(:to_hash).returns(:_timestamp => "1234")
@tw.result("template contents")
@@ -133,13 +132,11 @@ describe Puppet::Parser::TemplateWrapper do
%w{! . ; :}.each do |badchar|
it "should translate #{badchar} to _ when setting the instance variables" do
- template_mock = mock("template", :result => "woot!")
- ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
+ mock_template
+ @scope.expects(:to_hash).returns("one#{badchar}" => "foo")
+ @tw.result("template contents")
- @scope.expects(:to_hash).returns("one#{badchar}" => "foo")
- @tw.result("template contents")
-
- @tw.instance_variable_get("@one_").should == "foo"
- end
+ @tw.instance_variable_get("@one_").should == "foo"
+ end
end
end
diff --git a/spec/unit/parser/type_loader_spec.rb b/spec/unit/parser/type_loader_spec.rb
index 12bc1ccd6..9367b61c8 100644..100755
--- a/spec/unit/parser/type_loader_spec.rb
+++ b/spec/unit/parser/type_loader_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/parser/type_loader'
require 'puppet_spec/files'
diff --git a/spec/unit/property/ensure_spec.rb b/spec/unit/property/ensure_spec.rb
index d3029c658..35151553b 100644..100755
--- a/spec/unit/property/ensure_spec.rb
+++ b/spec/unit/property/ensure_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/property/ensure'
diff --git a/spec/unit/property/keyvalue_spec.rb b/spec/unit/property/keyvalue_spec.rb
index a0175cfa3..821c61799 100644..100755
--- a/spec/unit/property/keyvalue_spec.rb
+++ b/spec/unit/property/keyvalue_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/property/keyvalue'
diff --git a/spec/unit/property/list_spec.rb b/spec/unit/property/list_spec.rb
index 704fbe3d9..a29d65751 100644..100755
--- a/spec/unit/property/list_spec.rb
+++ b/spec/unit/property/list_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/property/list'
diff --git a/spec/unit/property/ordered_list_spec.rb b/spec/unit/property/ordered_list_spec.rb
index 460bec79d..2ad05367c 100644..100755
--- a/spec/unit/property/ordered_list_spec.rb
+++ b/spec/unit/property/ordered_list_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/property/ordered_list'
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 602d3c66b..7728b5d40 100755
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/property'
describe Puppet::Property do
diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb
index c65f39097..5bb98eadf 100644..100755
--- a/spec/unit/provider/augeas/augeas_spec.rb
+++ b/spec/unit/provider/augeas/augeas_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:augeas).provider(:augeas)
diff --git a/spec/unit/provider/confine/exists_spec.rb b/spec/unit/provider/confine/exists_spec.rb
index 1dabafb19..1e2d7f86f 100755
--- a/spec/unit/provider/confine/exists_spec.rb
+++ b/spec/unit/provider/confine/exists_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confine/exists'
diff --git a/spec/unit/provider/confine/false_spec.rb b/spec/unit/provider/confine/false_spec.rb
index 8ea4bf740..1afa57cbc 100755
--- a/spec/unit/provider/confine/false_spec.rb
+++ b/spec/unit/provider/confine/false_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confine/false'
diff --git a/spec/unit/provider/confine/feature_spec.rb b/spec/unit/provider/confine/feature_spec.rb
index 534c8c14a..959c7a3bb 100755
--- a/spec/unit/provider/confine/feature_spec.rb
+++ b/spec/unit/provider/confine/feature_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confine/feature'
diff --git a/spec/unit/provider/confine/true_spec.rb b/spec/unit/provider/confine/true_spec.rb
index b23373b87..795819bd3 100755
--- a/spec/unit/provider/confine/true_spec.rb
+++ b/spec/unit/provider/confine/true_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confine/true'
diff --git a/spec/unit/provider/confine/variable_spec.rb b/spec/unit/provider/confine/variable_spec.rb
index 083573c3a..7b9f53c3d 100755
--- a/spec/unit/provider/confine/variable_spec.rb
+++ b/spec/unit/provider/confine/variable_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confine/variable'
diff --git a/spec/unit/provider/confine_collection_spec.rb b/spec/unit/provider/confine_collection_spec.rb
index fc68ef7f6..f1dbaf35d 100755
--- a/spec/unit/provider/confine_collection_spec.rb
+++ b/spec/unit/provider/confine_collection_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confine_collection'
diff --git a/spec/unit/provider/confine_spec.rb b/spec/unit/provider/confine_spec.rb
index ce969eded..ade444276 100755
--- a/spec/unit/provider/confine_spec.rb
+++ b/spec/unit/provider/confine_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confine'
diff --git a/spec/unit/provider/confiner_spec.rb b/spec/unit/provider/confiner_spec.rb
index 15e2e6129..23ec162a5 100755
--- a/spec/unit/provider/confiner_spec.rb
+++ b/spec/unit/provider/confiner_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/confiner'
diff --git a/spec/unit/provider/exec/posix_spec.rb b/spec/unit/provider/exec/posix_spec.rb
index d02099250..50697d826 100755
--- a/spec/unit/provider/exec/posix_spec.rb
+++ b/spec/unit/provider/exec/posix_spec.rb
@@ -1,5 +1,5 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:exec).provider(:posix)
diff --git a/spec/unit/provider/exec/shell_spec.rb b/spec/unit/provider/exec/shell_spec.rb
index 4bae354c9..90047b9d6 100644..100755
--- a/spec/unit/provider/exec/shell_spec.rb
+++ b/spec/unit/provider/exec/shell_spec.rb
@@ -1,5 +1,5 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:exec).provider(:shell)
diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb
index 41431fb59..585eb02af 100755
--- a/spec/unit/provider/group/groupadd_spec.rb
+++ b/spec/unit/provider/group/groupadd_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:group).provider(:groupadd)
@@ -10,10 +9,10 @@ describe provider_class do
@provider = provider_class.new(@resource)
end
- # #1360
it "should add -o when allowdupe is enabled and the group is being created" do
@resource.stubs(:should).returns "fakeval"
@resource.stubs(:[]).returns "fakeval"
+ @resource.stubs(:system?).returns true
@resource.expects(:allowdupe?).returns true
@provider.expects(:execute).with { |args| args.include?("-o") }
@@ -28,4 +27,14 @@ describe provider_class do
@provider.gid = 150
end
+
+ it "should add -r when system is enabled and the group is being created" do
+ @resource.stubs(:should).returns "fakeval"
+ @resource.stubs(:[]).returns "fakeval"
+ @resource.expects(:system?).returns true
+ @resource.stubs(:allowdupe?).returns true
+ @provider.expects(:execute).with { |args| args.include?("-r") }
+
+ @provider.create
+ end
end
diff --git a/spec/unit/provider/group/ldap_spec.rb b/spec/unit/provider/group/ldap_spec.rb
index 8454b9604..947007f10 100755
--- a/spec/unit/provider/group/ldap_spec.rb
+++ b/spec/unit/provider/group/ldap_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-10.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:group).provider(:ldap)
diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb
index 048d77ba2..9cb5890cc 100755
--- a/spec/unit/provider/host/parsed_spec.rb
+++ b/spec/unit/provider/host/parsed_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'shared_behaviours/all_parsedfile_providers'
require 'puppet_spec/files'
diff --git a/spec/unit/provider/interface/cisco_spec.rb b/spec/unit/provider/interface/cisco_spec.rb
new file mode 100755
index 000000000..d1f70609f
--- /dev/null
+++ b/spec/unit/provider/interface/cisco_spec.rb
@@ -0,0 +1,64 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+require 'puppet/provider/interface/cisco'
+
+provider_class = Puppet::Type.type(:interface).provider(:cisco)
+
+describe provider_class do
+ before do
+ @resource = stub("resource", :name => "Fa0/1")
+ @provider = provider_class.new(@resource)
+ end
+
+ it "should have a parent of Puppet::Provider::NetworkDevice" do
+ provider_class.should < Puppet::Provider::NetworkDevice
+ end
+
+ it "should have an instances method" do
+ provider_class.should respond_to(:instances)
+ end
+
+ describe "when looking up instances at prefetch" do
+ before do
+ @device = stub_everything 'device'
+ Puppet::Util::NetworkDevice::Cisco::Device.stubs(:new).returns(@device)
+ @device.stubs(:command).yields(@device)
+ end
+
+ it "should initialize the network device with the given url" do
+ Puppet::Util::NetworkDevice::Cisco::Device.expects(:new).with(:url).returns(@device)
+ provider_class.lookup(:url, "Fa0/1")
+ end
+
+ it "should delegate to the device interface fetcher" do
+ @device.expects(:interface)
+ provider_class.lookup("", "Fa0/1")
+ end
+
+ it "should return the given interface data" do
+ @device.expects(:interface).returns({ :description => "thisone", :mode => :access})
+ provider_class.lookup("", "Fa0").should == {:description => "thisone", :mode => :access }
+ end
+
+ end
+
+ describe "when an instance is being flushed" do
+ it "should call the device interface update method with current and past properties" do
+ @instance = provider_class.new(:ensure => :present, :name => "Fa0/1", :description => "myinterface")
+ @instance.description = "newdesc"
+ @instance.resource = @resource
+ @resource.stubs(:[]).with(:name).returns("Fa0/1")
+ device = stub_everything 'device'
+ @instance.stubs(:device).returns(device)
+ device.expects(:command).yields(device)
+ interface = stub 'interface'
+ device.expects(:new_interface).with("Fa0/1").returns(interface)
+ interface.expects(:update).with( {:ensure => :present, :name => "Fa0/1", :description => "myinterface"},
+ {:ensure => :present, :name => "Fa0/1", :description => "newdesc"})
+
+ @instance.flush
+ end
+ end
+end
diff --git a/spec/unit/provider/ldap_spec.rb b/spec/unit/provider/ldap_spec.rb
index 7ed289c62..012a22b99 100755
--- a/spec/unit/provider/ldap_spec.rb
+++ b/spec/unit/provider/ldap_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-21.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/provider/ldap'
diff --git a/spec/unit/provider/macauthorization_spec.rb b/spec/unit/provider/macauthorization_spec.rb
index 3c74334ba..a76f917f7 100755
--- a/spec/unit/provider/macauthorization_spec.rb
+++ b/spec/unit/provider/macauthorization_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the macauthorization provider
#
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet'
require 'facter/util/plist'
diff --git a/spec/unit/provider/mcx/mcxcontent_spec.rb b/spec/unit/provider/mcx/mcxcontent_spec.rb
index 82dbf9ac7..4676575be 100755
--- a/spec/unit/provider/mcx/mcxcontent_spec.rb
+++ b/spec/unit/provider/mcx/mcxcontent_spec.rb
@@ -1,24 +1,5 @@
-#! /usr/bin/env ruby
-#--
-# Copyright (C) 2008 Jeffrey J McCune.
-
-# This program and entire repository is free software; you can
-# redistribute it and/or modify it under the terms of the GNU
-# General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-# Author: Jeff McCune <mccune.jeff@gmail.com>
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:mcx).provider(:mcxcontent)
diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index b63c0751f..0293e0758 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-9-12.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'shared_behaviours/all_parsedfile_providers'
provider_class = Puppet::Type.type(:mount).provider(:parsed)
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index 9cadfc403..963bfba7c 100755
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/mount'
diff --git a/spec/unit/provider/naginator_spec.rb b/spec/unit/provider/naginator_spec.rb
index 8ae1895cc..1d8e78015 100755
--- a/spec/unit/provider/naginator_spec.rb
+++ b/spec/unit/provider/naginator_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/naginator'
diff --git a/spec/unit/provider/nameservice/directoryservice_spec.rb b/spec/unit/provider/nameservice/directoryservice_spec.rb
index 661899db9..47f2ad0cd 100755
--- a/spec/unit/provider/nameservice/directoryservice_spec.rb
+++ b/spec/unit/provider/nameservice/directoryservice_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
# We use this as a reasonable way to obtain all the support infrastructure.
[:user, :group].each do |type_for_this_round|
diff --git a/spec/unit/provider/network_device_spec.rb b/spec/unit/provider/network_device_spec.rb
new file mode 100755
index 000000000..83d2bdc01
--- /dev/null
+++ b/spec/unit/provider/network_device_spec.rb
@@ -0,0 +1,148 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/provider/network_device'
+
+Puppet::Type.type(:vlan).provide :test, :parent => Puppet::Provider::NetworkDevice do
+ mk_resource_methods
+ def self.lookup(device_url, name)
+ end
+end
+
+provider_class = Puppet::Type.type(:vlan).provider(:test)
+
+describe provider_class do
+ before do
+ @resource = stub("resource", :name => "test")
+ @provider = provider_class.new(@resource)
+ end
+
+ it "should be able to prefetch instances from the device" do
+ provider_class.should respond_to(:prefetch)
+ end
+
+ it "should have an instances method" do
+ provider_class.should respond_to(:instances)
+ end
+
+ describe "when prefetching" do
+ before do
+ @resource = stub_everything 'resource'
+ @resources = {"200" => @resource}
+ provider_class.stubs(:lookup)
+ end
+
+ it "should lookup an entry for each passed resource" do
+ provider_class.expects(:lookup).with(nil, "200").returns nil
+
+ provider_class.stubs(:new)
+ @resource.stubs(:provider=)
+ provider_class.prefetch(@resources)
+ end
+
+ describe "resources that do not exist" do
+ it "should create a provider with :ensure => :absent" do
+ provider_class.stubs(:lookup).returns(nil)
+ provider_class.expects(:new).with(:ensure => :absent).returns "myprovider"
+ @resource.expects(:provider=).with("myprovider")
+ provider_class.prefetch(@resources)
+ end
+ end
+
+ describe "resources that exist" do
+ it "should create a provider with the results of the find and ensure at present" do
+ provider_class.stubs(:lookup).returns({ :name => "200", :description => "myvlan"})
+
+ provider_class.expects(:new).with(:name => "200", :description => "myvlan", :ensure => :present).returns "myprovider"
+ @resource.expects(:provider=).with("myprovider")
+
+ provider_class.prefetch(@resources)
+ end
+ end
+ end
+
+ describe "when being initialized" do
+ describe "with a hash" do
+ before do
+ @resource_class = mock 'resource_class'
+ provider_class.stubs(:resource_type).returns @resource_class
+
+ @property_class = stub 'property_class', :array_matching => :all, :superclass => Puppet::Property
+ @resource_class.stubs(:attrclass).with(:one).returns(@property_class)
+ @resource_class.stubs(:valid_parameter?).returns true
+ end
+
+ it "should store a copy of the hash as its vlan_properties" do
+ instance = provider_class.new(:one => :two)
+ instance.former_properties.should == {:one => :two}
+ end
+ end
+ end
+
+ describe "when an instance" do
+ before do
+ @instance = provider_class.new
+
+ @property_class = stub 'property_class', :array_matching => :all, :superclass => Puppet::Property
+ @resource_class = stub 'resource_class', :attrclass => @property_class, :valid_parameter? => true, :validproperties => [:description]
+ provider_class.stubs(:resource_type).returns @resource_class
+ end
+
+ it "should have a method for creating the instance" do
+ @instance.should respond_to(:create)
+ end
+
+ it "should have a method for removing the instance" do
+ @instance.should respond_to(:destroy)
+ end
+
+ it "should indicate when the instance already exists" do
+ @instance = provider_class.new(:ensure => :present)
+ @instance.exists?.should be_true
+ end
+
+ it "should indicate when the instance does not exist" do
+ @instance = provider_class.new(:ensure => :absent)
+ @instance.exists?.should be_false
+ end
+
+ describe "is being flushed" do
+ it "should flush properties" do
+ @instance = provider_class.new(:ensure => :present, :name => "200", :description => "myvlan")
+ @instance.flush
+ @instance.properties.should be_empty
+ end
+ end
+
+ describe "is being created" do
+ before do
+ @rclass = mock 'resource_class'
+ @rclass.stubs(:validproperties).returns([:description])
+ @resource = stub_everything 'resource'
+ @resource.stubs(:class).returns @rclass
+ @resource.stubs(:should).returns nil
+ @instance.stubs(:resource).returns @resource
+ end
+
+ it "should set its :ensure value to :present" do
+ @instance.create
+ @instance.properties[:ensure].should == :present
+ end
+
+ it "should set all of the other attributes from the resource" do
+ @resource.expects(:should).with(:description).returns "myvlan"
+
+ @instance.create
+ @instance.properties[:description].should == "myvlan"
+ end
+ end
+
+ describe "is being destroyed" do
+ it "should set its :ensure value to :absent" do
+ @instance.destroy
+ @instance.properties[:ensure].should == :absent
+ end
+ end
+ end
+end
diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb
index 40e497c27..fba29d7a7 100755
--- a/spec/unit/provider/package/aix_spec.rb
+++ b/spec/unit/provider/package/aix_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:package).provider(:aix)
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index b0ce4f799..b020b0f4f 100755
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider = Puppet::Type.type(:package).provider(:apt)
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index 444fb31c1..e64146056 100755
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider = Puppet::Type.type(:package).provider(:dpkg)
diff --git a/spec/unit/provider/package/freebsd_spec.rb b/spec/unit/provider/package/freebsd_spec.rb
index 0d38a16cf..9c8038791 100755
--- a/spec/unit/provider/package/freebsd_spec.rb
+++ b/spec/unit/provider/package/freebsd_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:package).provider(:freebsd)
diff --git a/spec/unit/provider/package/gem_spec.rb b/spec/unit/provider/package/gem_spec.rb
index c2bd3cc90..284e63c23 100644..100755
--- a/spec/unit/provider/package/gem_spec.rb
+++ b/spec/unit/provider/package/gem_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:package).provider(:gem)
diff --git a/spec/unit/provider/package/hpux_spec.rb b/spec/unit/provider/package/hpux_spec.rb
index e75ae0822..b781f6540 100644..100755
--- a/spec/unit/provider/package/hpux_spec.rb
+++ b/spec/unit/provider/package/hpux_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:package).provider(:hpux)
diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb
new file mode 100755
index 000000000..7d1acd537
--- /dev/null
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -0,0 +1,122 @@
+require 'spec_helper'
+
+provider_class = Puppet::Type.type(:package).provider(:macports)
+
+describe provider_class do
+ let :resource_name do
+ "foo"
+ end
+
+ let :resource do
+ Puppet::Type.type(:package).new(:name => resource_name, :provider => :macports)
+ end
+
+ let :provider do
+ prov = resource.provider
+ prov.expects(:execute).never
+ prov
+ end
+
+ let :current_hash do
+ {:name => resource_name, :ensure => "1.2.3", :revision => "1", :provider => :macports}
+ end
+
+ describe "provider features" do
+ subject { provider }
+
+ it { should be_installable }
+ it { should be_uninstallable }
+ it { should be_upgradeable }
+ it { should be_versionable }
+ end
+
+ describe "when listing all instances" do
+ it "should call port -q installed" do
+ provider_class.expects(:port).with("-q", :installed).returns("")
+ provider_class.instances
+ end
+
+ it "should create instances from active ports" do
+ provider_class.expects(:port).returns("foo @1.234.5_2 (active)")
+ provider_class.instances.size.should == 1
+ end
+
+ it "should ignore ports that aren't activated" do
+ provider_class.expects(:port).returns("foo @1.234.5_2")
+ provider_class.instances.size.should == 0
+ end
+ end
+
+ describe "when installing" do
+ it "should not specify a version when ensure is set to latest" do
+ resource[:ensure] = :latest
+ provider.expects(:port).with { |flag, method, name, version|
+ version.should be_nil
+ }
+ provider.install
+ end
+
+ it "should not specify a version when ensure is set to present" do
+ resource[:ensure] = :present
+ provider.expects(:port).with { |flag, method, name, version|
+ version.should be_nil
+ }
+ provider.install
+ end
+
+ it "should specify a version when ensure is set to a version" do
+ resource[:ensure] = "1.2.3"
+ provider.expects(:port).with { |flag, method, name, version|
+ version.should be
+ }
+ provider.install
+ end
+ end
+
+ describe "when querying for the latest version" do
+ let :new_info_line do
+ "1.2.3 2"
+ end
+ let :infoargs do
+ ["-q", :info, "--line", "--version", "--revision", resource_name]
+ end
+
+ it "should return nil when the package cannot be found" do
+ resource[:name] = resource_name
+ provider.expects(:port).returns("")
+ provider.latest.should == nil
+ end
+
+ it "should return the current version if the installed port has the same revision" do
+ current_hash[:revision] = "2"
+ provider.expects(:port).with(*infoargs).returns(new_info_line)
+ provider.expects(:query).returns(current_hash)
+ provider.latest.should == current_hash[:ensure]
+ end
+
+ it "should return the new version_revision if the installed port has a lower revision" do
+ current_hash[:revision] = "1"
+ provider.expects(:port).with(*infoargs).returns(new_info_line)
+ provider.expects(:query).returns(current_hash)
+ provider.latest.should == "1.2.3_2"
+ end
+ end
+
+ describe "when updating a port" do
+ it "should execute port upgrade if the port is installed" do
+ resource[:name] = resource_name
+ resource[:ensure] = :present
+ provider.expects(:query).returns(current_hash)
+ provider.expects(:port).with("-q", :upgrade, resource_name)
+ provider.update
+ end
+
+ it "should execute port install if the port is not installed" do
+ resource[:name] = resource_name
+ resource[:ensure] = :present
+ provider.expects(:query).returns("")
+ provider.expects(:port).with("-q", :install, resource_name)
+ provider.update
+ end
+ end
+end
diff --git a/spec/unit/provider/package/nim_spec.rb b/spec/unit/provider/package/nim_spec.rb
index 74f903813..0fa9f580d 100755
--- a/spec/unit/provider/package/nim_spec.rb
+++ b/spec/unit/provider/package/nim_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:package).provider(:nim)
diff --git a/spec/unit/provider/package/pip_spec.rb b/spec/unit/provider/package/pip_spec.rb
index 8953b4b2c..b56271029 100644..100755
--- a/spec/unit/provider/package/pip_spec.rb
+++ b/spec/unit/provider/package/pip_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:package).provider(:pip)
diff --git a/spec/unit/provider/package/pkg_spec.rb b/spec/unit/provider/package/pkg_spec.rb
index 3455c4c40..04a4ae607 100644..100755
--- a/spec/unit/provider/package/pkg_spec.rb
+++ b/spec/unit/provider/package/pkg_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider = Puppet::Type.type(:package).provider(:pkg)
diff --git a/spec/unit/provider/package/pkgdmg_spec.rb b/spec/unit/provider/package/pkgdmg_spec.rb
index 86631e596..155f12e7b 100755
--- a/spec/unit/provider/package/pkgdmg_spec.rb
+++ b/spec/unit/provider/package/pkgdmg_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider = Puppet::Type.type(:package).provider(:pkgdmg)
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index 4e2294a77..601c24009 100644..100755
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider = Puppet::Type.type(:package).provider(:yum)
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 1bf27ad97..4218b14c7 100644..100755
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:package).provider(:zypper)
diff --git a/spec/unit/provider/parsedfile_spec.rb b/spec/unit/provider/parsedfile_spec.rb
index 7d95ef1d0..2ff904b7f 100755
--- a/spec/unit/provider/parsedfile_spec.rb
+++ b/spec/unit/provider/parsedfile_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/provider/parsedfile'
diff --git a/spec/unit/provider/selboolean_spec.rb b/spec/unit/provider/selboolean_spec.rb
index 02a39f2a7..64f925e1e 100755
--- a/spec/unit/provider/selboolean_spec.rb
+++ b/spec/unit/provider/selboolean_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:selboolean).provider(:getsetsebool)
diff --git a/spec/unit/provider/selmodule_spec.rb b/spec/unit/provider/selmodule_spec.rb
index cb143e993..67196667f 100755
--- a/spec/unit/provider/selmodule_spec.rb
+++ b/spec/unit/provider/selmodule_spec.rb
@@ -1,11 +1,11 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
# Note: This unit test depends on having a sample SELinux policy file
# in the same directory as this test called selmodule-example.pp
# with version 1.5.0. The provided selmodule-example.pp is the first
# 256 bytes taken from /usr/share/selinux/targeted/nagios.pp on Fedora 9
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:selmodule).provider(:semodule)
diff --git a/spec/unit/provider/service/daemontools_spec.rb b/spec/unit/provider/service/daemontools_spec.rb
index 0bdb0a85d..64eeb9fa4 100755
--- a/spec/unit/provider/service/daemontools_spec.rb
+++ b/spec/unit/provider/service/daemontools_spec.rb
@@ -1,10 +1,10 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the Daemontools service Provider
#
# author Brice Figureau
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:daemontools)
diff --git a/spec/unit/provider/service/debian_spec.rb b/spec/unit/provider/service/debian_spec.rb
index b5edf6882..4e3d30d61 100755
--- a/spec/unit/provider/service/debian_spec.rb
+++ b/spec/unit/provider/service/debian_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the debian service provider
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:debian)
diff --git a/spec/unit/provider/service/freebsd_spec.rb b/spec/unit/provider/service/freebsd_spec.rb
index d8b751108..c1a6d26f7 100644..100755
--- a/spec/unit/provider/service/freebsd_spec.rb
+++ b/spec/unit/provider/service/freebsd_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:freebsd)
diff --git a/spec/unit/provider/service/init_spec.rb b/spec/unit/provider/service/init_spec.rb
index b54c27e8e..d64e0fc5d 100755
--- a/spec/unit/provider/service/init_spec.rb
+++ b/spec/unit/provider/service/init_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the Init service Provider
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:init)
diff --git a/spec/unit/provider/service/launchd_spec.rb b/spec/unit/provider/service/launchd_spec.rb
index dfcb58fdc..8ae7f003d 100755
--- a/spec/unit/provider/service/launchd_spec.rb
+++ b/spec/unit/provider/service/launchd_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the launchd service provider
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet'
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index a3c6247dd..b7f56e089 100755
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -1,8 +1,8 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the RedHat service Provider
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:redhat)
diff --git a/spec/unit/provider/service/runit_spec.rb b/spec/unit/provider/service/runit_spec.rb
index 12dfeeb35..38855a451 100755
--- a/spec/unit/provider/service/runit_spec.rb
+++ b/spec/unit/provider/service/runit_spec.rb
@@ -1,10 +1,10 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the Runit service Provider
#
# author Brice Figureau
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:runit)
diff --git a/spec/unit/provider/service/smf_spec.rb b/spec/unit/provider/service/smf_spec.rb
index 40e96ab23..5212d540a 100755
--- a/spec/unit/provider/service/smf_spec.rb
+++ b/spec/unit/provider/service/smf_spec.rb
@@ -1,10 +1,10 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the SMF service Provider
#
# author Dominic Cleal
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:smf)
diff --git a/spec/unit/provider/service/src_spec.rb b/spec/unit/provider/service/src_spec.rb
index dbe073513..17f49994e 100755
--- a/spec/unit/provider/service/src_spec.rb
+++ b/spec/unit/provider/service/src_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Unit testing for the AIX System Resource Controller (src) provider
#
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:src)
diff --git a/spec/unit/provider/service/upstart.rb b/spec/unit/provider/service/upstart.rb
index 22cf2bdeb..0febc939d 100644..100755
--- a/spec/unit/provider/service/upstart.rb
+++ b/spec/unit/provider/service/upstart.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:service).provider(:upstart)
diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
index 3ac57facc..69d29c674 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'shared_behaviours/all_parsedfile_providers'
require 'puppet_spec/files'
diff --git a/spec/unit/provider/sshkey/parsed_spec.rb b/spec/unit/provider/sshkey/parsed_spec.rb
index 7a76b02d6..e66032bc4 100755
--- a/spec/unit/provider/sshkey/parsed_spec.rb
+++ b/spec/unit/provider/sshkey/parsed_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:sshkey).provider(:parsed)
diff --git a/spec/unit/provider/user/hpux_spec.rb b/spec/unit/provider/user/hpux_spec.rb
index b10f2847c..f7779a98d 100755
--- a/spec/unit/provider/user/hpux_spec.rb
+++ b/spec/unit/provider/user/hpux_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:user).provider(:hpuxuseradd)
diff --git a/spec/unit/provider/user/ldap_spec.rb b/spec/unit/provider/user/ldap_spec.rb
index 5b2dc98b5..065b3b423 100755
--- a/spec/unit/provider/user/ldap_spec.rb
+++ b/spec/unit/provider/user/ldap_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-10.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
provider_class = Puppet::Type.type(:user).provider(:ldap)
diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb
index 12a71d25a..b17ba68c8 100644..100755
--- a/spec/unit/provider/user/user_role_add_spec.rb
+++ b/spec/unit/provider/user/user_role_add_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:user).provider(:user_role_add)
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb
index b1719eeaf..724fc12c0 100755
--- a/spec/unit/provider/user/useradd_spec.rb
+++ b/spec/unit/provider/user/useradd_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:user).provider(:useradd)
diff --git a/spec/unit/provider/vlan/cisco_spec.rb b/spec/unit/provider/vlan/cisco_spec.rb
new file mode 100755
index 000000000..bb243a75e
--- /dev/null
+++ b/spec/unit/provider/vlan/cisco_spec.rb
@@ -0,0 +1,62 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+require 'puppet/provider/vlan/cisco'
+
+provider_class = Puppet::Type.type(:vlan).provider(:cisco)
+
+describe provider_class do
+ before do
+ @resource = stub("resource", :name => "200")
+ @provider = provider_class.new(@resource)
+ end
+
+ it "should have a parent of Puppet::Provider::NetworkDevice" do
+ provider_class.should < Puppet::Provider::NetworkDevice
+ end
+
+ it "should have an instances method" do
+ provider_class.should respond_to(:instances)
+ end
+
+ describe "when looking up instances at prefetch" do
+ before do
+ @device = stub_everything 'device'
+ Puppet::Util::NetworkDevice::Cisco::Device.stubs(:new).returns(@device)
+ @device.stubs(:command).yields(@device)
+ end
+
+ it "should initialize the network device with the given url" do
+ Puppet::Util::NetworkDevice::Cisco::Device.expects(:new).with(:url).returns(@device)
+ provider_class.lookup(:url, "200")
+ end
+
+ it "should delegate to the device vlans" do
+ @device.expects(:parse_vlans)
+ provider_class.lookup("", "200")
+ end
+
+ it "should return only the given vlan" do
+ @device.expects(:parse_vlans).returns({"200" => { :description => "thisone" }, "1" => { :description => "nothisone" }})
+ provider_class.lookup("", "200").should == {:description => "thisone" }
+ end
+
+ end
+
+ describe "when an instance is being flushed" do
+ it "should call the device update_vlan method with its vlan id, current attributes, and desired attributes" do
+ @instance = provider_class.new(:ensure => :present, :name => "200", :description => "myvlan")
+ @instance.description = "myvlan2"
+ @instance.resource = @resource
+ @resource.stubs(:[]).with(:name).returns("200")
+ device = stub_everything 'device'
+ @instance.stubs(:device).returns(device)
+ device.expects(:command).yields(device)
+ device.expects(:update_vlan).with(@instance.name, {:ensure => :present, :name => "200", :description => "myvlan"},
+ {:ensure => :present, :name => "200", :description => "myvlan2"})
+
+ @instance.flush
+ end
+ end
+end
diff --git a/spec/unit/provider/zfs/solaris_spec.rb b/spec/unit/provider/zfs/solaris_spec.rb
index 84a2be9f6..8a0cd23b1 100755
--- a/spec/unit/provider/zfs/solaris_spec.rb
+++ b/spec/unit/provider/zfs/solaris_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:zfs).provider(:solaris)
diff --git a/spec/unit/provider/zone/solaris_spec.rb b/spec/unit/provider/zone/solaris_spec.rb
index 4a1d03272..17ec8f68f 100755
--- a/spec/unit/provider/zone/solaris_spec.rb
+++ b/spec/unit/provider/zone/solaris_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:zone).provider(:solaris)
diff --git a/spec/unit/provider/zpool/solaris_spec.rb b/spec/unit/provider/zpool/solaris_spec.rb
index e2a0e16c8..7e3048a7a 100755
--- a/spec/unit/provider/zpool/solaris_spec.rb
+++ b/spec/unit/provider/zpool/solaris_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
provider_class = Puppet::Type.type(:zpool).provider(:solaris)
diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb
index 24f5216fe..4eb5e12de 100755
--- a/spec/unit/provider_spec.rb
+++ b/spec/unit/provider_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Provider do
it "should have a specifity class method" do
diff --git a/spec/unit/puppet/provider/README.markdown b/spec/unit/puppet/provider/README.markdown
new file mode 100644
index 000000000..702585021
--- /dev/null
+++ b/spec/unit/puppet/provider/README.markdown
@@ -0,0 +1,4 @@
+Provider Specs
+==============
+
+Define specs for your providers under this directory.
diff --git a/spec/unit/puppet/type/README.markdown b/spec/unit/puppet/type/README.markdown
new file mode 100644
index 000000000..1ee19ac84
--- /dev/null
+++ b/spec/unit/puppet/type/README.markdown
@@ -0,0 +1,4 @@
+Resource Type Specs
+===================
+
+Define specs for your resource types in this directory.
diff --git a/spec/unit/puppet_spec.rb b/spec/unit/puppet_spec.rb
index 28dbd5104..50d3a4718 100755
--- a/spec/unit/puppet_spec.rb
+++ b/spec/unit/puppet_spec.rb
@@ -1,6 +1,6 @@
-#!/usr/bin/env ruby"
+#!/usr/bin/env rspec"
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
require 'puppet'
describe Puppet do
diff --git a/spec/unit/rails/host_spec.rb b/spec/unit/rails/host_spec.rb
index e83135c91..df0b2fa1d 100755
--- a/spec/unit/rails/host_spec.rb
+++ b/spec/unit/rails/host_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe "Puppet::Rails::Host", :if => Puppet.features.rails? do
def column(name, type)
diff --git a/spec/unit/rails/param_value_spec.rb b/spec/unit/rails/param_value_spec.rb
index 9a725cfc8..7f0086252 100755
--- a/spec/unit/rails/param_value_spec.rb
+++ b/spec/unit/rails/param_value_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/rails'
describe "Puppet::Rails::ParamValue", :if => Puppet.features.rails? do
diff --git a/spec/unit/rails/resource_spec.rb b/spec/unit/rails/resource_spec.rb
index 3fbbbc7b7..22e5267f4 100755
--- a/spec/unit/rails/resource_spec.rb
+++ b/spec/unit/rails/resource_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/rails'
describe "Puppet::Rails::Resource", :if => Puppet.features.rails? do
diff --git a/spec/unit/rails_spec.rb b/spec/unit/rails_spec.rb
index a08485e4c..fe7fd8e29 100755
--- a/spec/unit/rails_spec.rb
+++ b/spec/unit/rails_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/rails'
describe Puppet::Rails, "when initializing any connection", :if => Puppet.features.rails? do
diff --git a/spec/unit/relationship_spec.rb b/spec/unit/relationship_spec.rb
index 362d74c74..a7e787b46 100755
--- a/spec/unit/relationship_spec.rb
+++ b/spec/unit/relationship_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-11-1.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
require 'puppet/relationship'
describe Puppet::Relationship do
diff --git a/spec/unit/reports/http_spec.rb b/spec/unit/reports/http_spec.rb
index a62793ed5..d7c37bfdd 100644..100755
--- a/spec/unit/reports/http_spec.rb
+++ b/spec/unit/reports/http_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/reports'
diff --git a/spec/unit/reports/rrdgraph_spec.rb b/spec/unit/reports/rrdgraph_spec.rb
index 5215f1dcc..3c2704a7a 100644..100755
--- a/spec/unit/reports/rrdgraph_spec.rb
+++ b/spec/unit/reports/rrdgraph_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/reports'
diff --git a/spec/unit/reports/store_spec.rb b/spec/unit/reports/store_spec.rb
index d48f6a846..73a7e353f 100644..100755
--- a/spec/unit/reports/store_spec.rb
+++ b/spec/unit/reports/store_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/reports'
require 'time'
diff --git a/spec/unit/reports/tagmail_spec.rb b/spec/unit/reports/tagmail_spec.rb
index 716bcbc04..a53d11978 100755
--- a/spec/unit/reports/tagmail_spec.rb
+++ b/spec/unit/reports/tagmail_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/reports'
diff --git a/spec/unit/reports_spec.rb b/spec/unit/reports_spec.rb
index a9d10be17..a4b2e04a9 100755
--- a/spec/unit/reports_spec.rb
+++ b/spec/unit/reports_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/reports'
diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb
index 78d1b3223..ae65aa91a 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Resource::Catalog, "when compiling" do
diff --git a/spec/unit/resource/status_spec.rb b/spec/unit/resource/status_spec.rb
index 343b8d318..bb88518c0 100755
--- a/spec/unit/resource/status_spec.rb
+++ b/spec/unit/resource/status_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/resource/status'
diff --git a/spec/unit/resource/type_collection_helper_spec.rb b/spec/unit/resource/type_collection_helper_spec.rb
index 442cfd076..ad8d75271 100644..100755
--- a/spec/unit/resource/type_collection_helper_spec.rb
+++ b/spec/unit/resource/type_collection_helper_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/resource/type_collection_helper'
diff --git a/spec/unit/resource/type_collection_spec.rb b/spec/unit/resource/type_collection_spec.rb
index 278e629bd..0c997c2ad 100644..100755
--- a/spec/unit/resource/type_collection_spec.rb
+++ b/spec/unit/resource/type_collection_spec.rb
@@ -1,11 +1,12 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/resource/type_collection'
require 'puppet/resource/type'
describe Puppet::Resource::TypeCollection do
+ include PuppetSpec::Files
+
before do
@instance = Puppet::Resource::Type.new(:hostclass, "foo")
@code = Puppet::Resource::TypeCollection.new("env")
@@ -82,11 +83,14 @@ describe Puppet::Resource::TypeCollection do
loader.add Puppet::Resource::Type.new(:hostclass, "class")
loader.add Puppet::Resource::Type.new(:definition, "define")
loader.add Puppet::Resource::Type.new(:node, "node")
+ watched_file = tmpfile('watched_file')
+ loader.watch_file(watched_file)
loader.clear
loader.hostclass("class").should be_nil
loader.definition("define").should be_nil
loader.node("node").should be_nil
+ loader.should_not be_watching_file(watched_file)
end
describe "when resolving namespaces" do
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb
index 41b5554d9..352f767e4 100755
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/resource/type'
@@ -237,35 +236,6 @@ describe Puppet::Resource::Type do
end
end
- describe "when creating a subscope" do
- before do
- @scope = stub 'scope', :newscope => nil
- @resource = stub 'resource'
- @type = Puppet::Resource::Type.new(:hostclass, "foo")
- end
-
- it "should return a new scope created with the provided scope as the parent" do
- @scope.expects(:newscope).returns "foo"
- @type.subscope(@scope, @resource).should == "foo"
- end
-
- it "should set the source as itself" do
- @scope.expects(:newscope).with { |args| args[:source] == @type }
- @type.subscope(@scope, @resource)
- end
-
- it "should set the scope's namespace to its namespace" do
- @type.expects(:namespace).returns "yayness"
- @scope.expects(:newscope).with { |args| args[:namespace] == "yayness" }
- @type.subscope(@scope, @resource)
- end
-
- it "should set the scope's resource to the provided resource" do
- @scope.expects(:newscope).with { |args| args[:resource] == @resource }
- @type.subscope(@scope, @resource)
- end
- end
-
describe "when setting its parameters in the scope" do
before do
@scope = Puppet::Parser::Scope.new(:compiler => stub("compiler", :environment => Puppet::Node::Environment.new), :source => stub("source"))
@@ -465,7 +435,7 @@ describe Puppet::Resource::Type do
it "should set all of its parameters in a subscope" do
subscope = stub 'subscope', :compiler => @compiler
- @type.expects(:subscope).with(@scope, @resource).returns subscope
+ @scope.expects(:newscope).with(:source => @type, :dynamic => true, :namespace => 'foo', :resource => @resource).returns subscope
@type.expects(:set_resource_parameters).with(@resource, subscope)
@type.evaluate_code(@resource)
@@ -493,8 +463,9 @@ describe Puppet::Resource::Type do
it "should evaluate the AST code if any is provided" do
code = stub 'code'
@type.stubs(:code).returns code
- @type.stubs(:subscope).returns stub_everything("subscope", :compiler => @compiler)
- code.expects(:safeevaluate).with @type.subscope
+ subscope = stub_everything("subscope", :compiler => @compiler)
+ @scope.stubs(:newscope).returns subscope
+ code.expects(:safeevaluate).with subscope
@type.evaluate_code(@resource)
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 916741d1a..79ea69e9c 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/resource'
describe Puppet::Resource do
diff --git a/spec/unit/run_spec.rb b/spec/unit/run_spec.rb
index 6c5ecde65..ea6ec74b1 100755
--- a/spec/unit/run_spec.rb
+++ b/spec/unit/run_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/agent'
require 'puppet/run'
diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb
index 99db2a55c..c8fea3b58 100755
--- a/spec/unit/simple_graph_spec.rb
+++ b/spec/unit/simple_graph_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-11-1.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
require 'puppet/simple_graph'
describe Puppet::SimpleGraph do
diff --git a/spec/unit/ssl/base_spec.rb b/spec/unit/ssl/base_spec.rb
index 99038391f..125623b70 100755
--- a/spec/unit/ssl/base_spec.rb
+++ b/spec/unit/ssl/base_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/certificate'
@@ -40,4 +39,4 @@ describe Puppet::SSL::Certificate do
@base.fingerprint(:digest).should == "DI:GE:ST"
end
end
-end \ No newline at end of file
+end
diff --git a/spec/unit/ssl/certificate_authority/interface_spec.rb b/spec/unit/ssl/certificate_authority/interface_spec.rb
index 2e4a3fc77..9e858dd54 100755
--- a/spec/unit/ssl/certificate_authority/interface_spec.rb
+++ b/spec/unit/ssl/certificate_authority/interface_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/certificate_authority'
diff --git a/spec/unit/ssl/certificate_authority_spec.rb b/spec/unit/ssl/certificate_authority_spec.rb
index 76633b48f..3aedfdc25 100755
--- a/spec/unit/ssl/certificate_authority_spec.rb
+++ b/spec/unit/ssl/certificate_authority_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/certificate_authority'
diff --git a/spec/unit/ssl/certificate_factory_spec.rb b/spec/unit/ssl/certificate_factory_spec.rb
index c2bcb19ce..f34dafe43 100755
--- a/spec/unit/ssl/certificate_factory_spec.rb
+++ b/spec/unit/ssl/certificate_factory_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/certificate_factory'
diff --git a/spec/unit/ssl/certificate_request_spec.rb b/spec/unit/ssl/certificate_request_spec.rb
index 32c9cb51d..e45f0130b 100755
--- a/spec/unit/ssl/certificate_request_spec.rb
+++ b/spec/unit/ssl/certificate_request_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/certificate_request'
require 'puppet/ssl/key'
diff --git a/spec/unit/ssl/certificate_revocation_list_spec.rb b/spec/unit/ssl/certificate_revocation_list_spec.rb
index e83ad9cc5..99058b353 100755
--- a/spec/unit/ssl/certificate_revocation_list_spec.rb
+++ b/spec/unit/ssl/certificate_revocation_list_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/certificate_revocation_list'
diff --git a/spec/unit/ssl/certificate_spec.rb b/spec/unit/ssl/certificate_spec.rb
index b3af9f236..0b635f2bc 100755
--- a/spec/unit/ssl/certificate_spec.rb
+++ b/spec/unit/ssl/certificate_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/certificate'
diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb
index 885bd45e2..2624c2234 100755
--- a/spec/unit/ssl/host_spec.rb
+++ b/spec/unit/ssl/host_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/host'
require 'puppet/sslcertificates'
diff --git a/spec/unit/ssl/inventory_spec.rb b/spec/unit/ssl/inventory_spec.rb
index 4d47a37c6..d8606b1b4 100755
--- a/spec/unit/ssl/inventory_spec.rb
+++ b/spec/unit/ssl/inventory_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/inventory'
diff --git a/spec/unit/ssl/key_spec.rb b/spec/unit/ssl/key_spec.rb
index e0667a5cc..cddf9f8ea 100755
--- a/spec/unit/ssl/key_spec.rb
+++ b/spec/unit/ssl/key_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/ssl/key'
diff --git a/spec/unit/sslcertificates/ca_spec.rb b/spec/unit/sslcertificates/ca_spec.rb
index 4e44f2d90..eea246ba1 100644..100755
--- a/spec/unit/sslcertificates/ca_spec.rb
+++ b/spec/unit/sslcertificates/ca_spec.rb
@@ -1,5 +1,5 @@
-#!/usr/bin/env ruby
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet'
require 'puppet/sslcertificates'
diff --git a/spec/unit/status_spec.rb b/spec/unit/status_spec.rb
index 3a9c805b3..820807638 100644..100755
--- a/spec/unit/status_spec.rb
+++ b/spec/unit/status_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Status do
it "should implement find" do
diff --git a/spec/unit/transaction/event_manager_spec.rb b/spec/unit/transaction/event_manager_spec.rb
index e45fbdf78..d127d0391 100755
--- a/spec/unit/transaction/event_manager_spec.rb
+++ b/spec/unit/transaction/event_manager_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/transaction/event_manager'
diff --git a/spec/unit/transaction/event_spec.rb b/spec/unit/transaction/event_spec.rb
index c77716cd6..1227802a7 100755
--- a/spec/unit/transaction/event_spec.rb
+++ b/spec/unit/transaction/event_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/transaction/event'
diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb
index a3bfe1e82..191a30eb7 100755
--- a/spec/unit/transaction/report_spec.rb
+++ b/spec/unit/transaction/report_spec.rb
@@ -1,10 +1,10 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/transaction/report'
describe Puppet::Transaction::Report do
+ include PuppetSpec::Files
before do
Puppet::Util::Storage.stubs(:store)
end
@@ -38,6 +38,24 @@ describe Puppet::Transaction::Report do
report.configuration_version.should == "some version"
end
+ it "should not include whits" do
+ Puppet::FileBucket::File.indirection.stubs(:save)
+
+ filename = tmpfile('whit_test')
+ file = Puppet::Type.type(:file).new(:path => filename)
+
+ catalog = Puppet::Resource::Catalog.new
+ catalog.add_resource(file)
+
+ report = Puppet::Transaction::Report.new("apply")
+
+ catalog.apply(:report => report)
+ report.finalize_report
+
+ report.resource_statuses.values.any? {|res| res.resource_type =~ /whit/i}.should be_false
+ report.metrics['time'].values.any? {|metric| metric.first =~ /whit/i}.should be_false
+ end
+
describe "when accepting logs" do
before do
@report = Puppet::Transaction::Report.new("apply")
diff --git a/spec/unit/transaction/resource_harness_spec.rb b/spec/unit/transaction/resource_harness_spec.rb
index 168b50287..20a42d27b 100755
--- a/spec/unit/transaction/resource_harness_spec.rb
+++ b/spec/unit/transaction/resource_harness_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/transaction/resource_harness'
diff --git a/spec/unit/transaction_spec.rb b/spec/unit/transaction_spec.rb
index ab76130e3..4157e58ac 100755
--- a/spec/unit/transaction_spec.rb
+++ b/spec/unit/transaction_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/transaction'
diff --git a/spec/unit/transportable_spec.rb b/spec/unit/transportable_spec.rb
index e69de29bb..e69de29bb 100644..100755
--- a/spec/unit/transportable_spec.rb
+++ b/spec/unit/transportable_spec.rb
diff --git a/spec/unit/type/augeas_spec.rb b/spec/unit/type/augeas_spec.rb
index dece395e1..c8dc207f9 100644..100755
--- a/spec/unit/type/augeas_spec.rb
+++ b/spec/unit/type/augeas_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
augeas = Puppet::Type.type(:augeas)
diff --git a/spec/unit/type/component_spec.rb b/spec/unit/type/component_spec.rb
index 60abfafbf..9d6d71926 100755
--- a/spec/unit/type/component_spec.rb
+++ b/spec/unit/type/component_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
component = Puppet::Type.type(:component)
diff --git a/spec/unit/type/computer_spec.rb b/spec/unit/type/computer_spec.rb
index 3177884f7..1e15d7a4f 100755
--- a/spec/unit/type/computer_spec.rb
+++ b/spec/unit/type/computer_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
computer = Puppet::Type.type(:computer)
diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb
index 5466b4d58..7bf92eb02 100755
--- a/spec/unit/type/cron_spec.rb
+++ b/spec/unit/type/cron_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:cron) do
before do
@@ -478,4 +477,14 @@ describe Puppet::Type.type(:cron) do
end
end
+
+ it "should require a command when adding an entry" do
+ entry = @class.new(:name => "test_entry", :ensure => :present)
+ expect { entry.value(:command) }.should raise_error(/No command/)
+ end
+
+ it "should not require a command when removing an entry" do
+ entry = @class.new(:name => "test_entry", :ensure => :absent)
+ entry.value(:command).should == nil
+ end
end
diff --git a/spec/unit/type/exec_spec.rb b/spec/unit/type/exec_spec.rb
index 86b824423..47d1b8523 100755
--- a/spec/unit/type/exec_spec.rb
+++ b/spec/unit/type/exec_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:exec) do
def exec_tester(command, exitstatus = 0, rest = {})
diff --git a/spec/unit/type/file/checksum_spec.rb b/spec/unit/type/file/checksum_spec.rb
index 16e8e99e1..b47f617cc 100644..100755
--- a/spec/unit/type/file/checksum_spec.rb
+++ b/spec/unit/type/file/checksum_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
checksum = Puppet::Type.type(:file).attrclass(:checksum)
describe checksum do
diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb
index 7abc7c433..7af5f9d83 100755
--- a/spec/unit/type/file/content_spec.rb
+++ b/spec/unit/type/file/content_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
content = Puppet::Type.type(:file).attrclass(:content)
describe content do
diff --git a/spec/unit/type/file/ctime.rb b/spec/unit/type/file/ctime.rb
index 9fb892aed..1700d4928 100644..100755
--- a/spec/unit/type/file/ctime.rb
+++ b/spec/unit/type/file/ctime.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:file).attrclass(:ctime) do
require 'puppet_spec/files'
diff --git a/spec/unit/type/file/ensure_spec.rb b/spec/unit/type/file/ensure_spec.rb
index c5351309e..8555ef035 100755
--- a/spec/unit/type/file/ensure_spec.rb
+++ b/spec/unit/type/file/ensure_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
property = Puppet::Type.type(:file).attrclass(:ensure)
diff --git a/spec/unit/type/file/group_spec.rb b/spec/unit/type/file/group_spec.rb
index 37a6872bd..707a37cd6 100755
--- a/spec/unit/type/file/group_spec.rb
+++ b/spec/unit/type/file/group_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
property = Puppet::Type.type(:file).attrclass(:group)
diff --git a/spec/unit/type/file/mtime.rb b/spec/unit/type/file/mtime.rb
index fa61bc343..3222df095 100644..100755
--- a/spec/unit/type/file/mtime.rb
+++ b/spec/unit/type/file/mtime.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:file).attrclass(:mtime) do
require 'puppet_spec/files'
diff --git a/spec/unit/type/file/owner_spec.rb b/spec/unit/type/file/owner_spec.rb
index 375faa237..ed3bef1fe 100755
--- a/spec/unit/type/file/owner_spec.rb
+++ b/spec/unit/type/file/owner_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
property = Puppet::Type.type(:file).attrclass(:owner)
diff --git a/spec/unit/type/file/selinux_spec.rb b/spec/unit/type/file/selinux_spec.rb
index 45e8b3b14..2622948d0 100644..100755
--- a/spec/unit/type/file/selinux_spec.rb
+++ b/spec/unit/type/file/selinux_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
[:seluser, :selrole, :seltype, :selrange].each do |param|
diff --git a/spec/unit/type/file/source_spec.rb b/spec/unit/type/file/source_spec.rb
index bb83e7531..5665d323d 100755
--- a/spec/unit/type/file/source_spec.rb
+++ b/spec/unit/type/file/source_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
source = Puppet::Type.type(:file).attrclass(:source)
describe Puppet::Type.type(:file).attrclass(:source) do
@@ -187,6 +186,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
describe "and the source is a link" do
it "should set the target to the link destination" do
@metadata.stubs(:ftype).returns "link"
+ @metadata.stubs(:links).returns "manage"
@resource.stubs(:[])
@resource.stubs(:[]=)
diff --git a/spec/unit/type/file/type.rb b/spec/unit/type/file/type.rb
index 0d38b64cd..7d4af0e16 100644..100755
--- a/spec/unit/type/file/type.rb
+++ b/spec/unit/type/file/type.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:file).attrclass(:type) do
require 'puppet_spec/files'
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb
index b15d41d4b..683c3654b 100755
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:file) do
before do
diff --git a/spec/unit/type/filebucket_spec.rb b/spec/unit/type/filebucket_spec.rb
index 7fcbacc4f..3c5311184 100644..100755
--- a/spec/unit/type/filebucket_spec.rb
+++ b/spec/unit/type/filebucket_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:filebucket) do
describe "when validating attributes" do
diff --git a/spec/unit/type/group_spec.rb b/spec/unit/type/group_spec.rb
index 43fdfcd4d..42fd3fb7b 100755
--- a/spec/unit/type/group_spec.rb
+++ b/spec/unit/type/group_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:group) do
before do
@@ -16,6 +15,10 @@ describe Puppet::Type.type(:group) do
@class.defaultprovider.ancestors.should be_include(Puppet::Provider)
end
+ it "should have a system_groups feature" do
+ @class.provider_feature(:system_groups).should_not be_nil
+ end
+
describe "when validating attributes" do
[:name, :allowdupe].each do |param|
it "should have a #{param} parameter" do
@@ -38,11 +41,14 @@ describe Puppet::Type.type(:group) do
end
end
- # #1407 - we need to declare the allowdupe param as boolean.
it "should have a boolean method for determining if duplicates are allowed" do
@class.new(:name => "foo").methods.should be_include("allowdupe?")
end
+ it "should have a boolean method for determining if system groups are allowed" do
+ @class.new(:name => "foo").methods.should be_include("system?")
+ end
+
it "should call 'create' to create the group" do
group = @class.new(:name => "foo", :ensure => :present)
group.provider.expects(:create)
diff --git a/spec/unit/type/host_spec.rb b/spec/unit/type/host_spec.rb
index 60ce73c6d..602c428af 100755
--- a/spec/unit/type/host_spec.rb
+++ b/spec/unit/type/host_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
host = Puppet::Type.type(:host)
diff --git a/spec/unit/type/interface_spec.rb b/spec/unit/type/interface_spec.rb
new file mode 100755
index 000000000..68f4c765f
--- /dev/null
+++ b/spec/unit/type/interface_spec.rb
@@ -0,0 +1,93 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Puppet::Type.type(:interface) do
+ it "should have a 'name' parameter'" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1")[:name].should == "FastEthernet 0/1"
+ end
+
+ it "should have a 'device_url' parameter'" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :device_url => :device)[:device_url].should == :device
+ end
+
+ it "should have an ensure property" do
+ Puppet::Type.type(:interface).attrtype(:ensure).should == :property
+ end
+
+ [:description, :speed, :duplex, :native_vlan, :encapsulation, :mode, :allowed_trunk_vlans, :etherchannel, :ipaddress].each do |p|
+ it "should have a #{p} property" do
+ Puppet::Type.type(:interface).attrtype(p).should == :property
+ end
+ end
+
+ describe "when validating attribute values" do
+ before do
+ @provider = stub 'provider', :class => Puppet::Type.type(:interface).defaultprovider, :clear => nil
+ Puppet::Type.type(:interface).defaultprovider.stubs(:new).returns(@provider)
+ end
+
+ it "should support :present as a value to :ensure" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ensure => :present)
+ end
+
+ it "should support :shutdown as a value to :ensure" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ensure => :shutdown)
+ end
+
+ it "should support :no_shutdown as a value to :ensure" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ensure => :no_shutdown)
+ end
+
+ describe "especially speed" do
+ it "should allow a number" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :speed => "100")
+ end
+
+ it "should allow :auto" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :speed => :auto)
+ end
+ end
+
+ describe "especially duplex" do
+ it "should allow :half" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :duplex => :half)
+ end
+
+ it "should allow :full" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :duplex => :full)
+ end
+
+ it "should allow :auto" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :duplex => :auto)
+ end
+ end
+
+ describe "especially ipaddress" do
+ it "should allow ipv4 addresses" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ipaddress => "192.168.0.1/24")
+ end
+
+ it "should allow arrays of ipv4 addresses" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ipaddress => ["192.168.0.1/24", "192.168.1.0/24"])
+ end
+
+ it "should allow ipv6 addresses" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ipaddress => "f0e9::/64")
+ end
+
+ it "should allow ipv6 options" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ipaddress => "f0e9::/64 link-local")
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ipaddress => "f0e9::/64 eui-64")
+ end
+
+ it "should allow a mix of ipv4 and ipv6" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ipaddress => ["192.168.0.1/24", "f0e9::/64 link-local"])
+ end
+
+ it "should munge ip addresses to a computer format" do
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1", :ipaddress => "192.168.0.1/24")[:ipaddress].should == [[24, IPAddr.new('192.168.0.1'), nil]]
+ end
+ end
+ end
+end
diff --git a/spec/unit/type/macauthorization_spec.rb b/spec/unit/type/macauthorization_spec.rb
index e0d3b9433..8ab30834b 100755
--- a/spec/unit/type/macauthorization_spec.rb
+++ b/spec/unit/type/macauthorization_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
macauth_type = Puppet::Type.type(:macauthorization)
diff --git a/spec/unit/type/maillist_spec.rb b/spec/unit/type/maillist_spec.rb
index 7e96b4760..ae5fcd5b3 100755
--- a/spec/unit/type/maillist_spec.rb
+++ b/spec/unit/type/maillist_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
maillist = Puppet::Type.type(:maillist)
diff --git a/spec/unit/type/mcx_spec.rb b/spec/unit/type/mcx_spec.rb
index 4b60a5c96..02f691a52 100755
--- a/spec/unit/type/mcx_spec.rb
+++ b/spec/unit/type/mcx_spec.rb
@@ -1,26 +1,5 @@
-#!/usr/bin/env ruby
-#--
-# Copyright (C) 2008 Jeffrey J McCune.
-
-# This program and entire repository is free software; you can
-# redistribute it and/or modify it under the terms of the GNU
-# General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-# Author: Jeff McCune <mccune.jeff@gmail.com>
-
-# Most of this code copied from /spec/type/service.rb
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/type/mcx'
diff --git a/spec/unit/type/mount_spec.rb b/spec/unit/type/mount_spec.rb
index 4638e9a2e..9ef76992a 100755
--- a/spec/unit/type/mount_spec.rb
+++ b/spec/unit/type/mount_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:mount) do
it "should have a :refreshable feature that requires the :remount method" do
diff --git a/spec/unit/type/nagios_spec.rb b/spec/unit/type/nagios_spec.rb
index 1515c2ae9..d650723c8 100755
--- a/spec/unit/type/nagios_spec.rb
+++ b/spec/unit/type/nagios_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/external/nagios'
diff --git a/spec/unit/type/noop_metaparam_spec.rb b/spec/unit/type/noop_metaparam_spec.rb
index 6f8f87e6c..f4241d417 100755
--- a/spec/unit/type/noop_metaparam_spec.rb
+++ b/spec/unit/type/noop_metaparam_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/type'
diff --git a/spec/unit/type/package_spec.rb b/spec/unit/type/package_spec.rb
index 3db9c77be..e75f7d290 100755
--- a/spec/unit/type/package_spec.rb
+++ b/spec/unit/type/package_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:package) do
before do
diff --git a/spec/unit/type/resources_spec.rb b/spec/unit/type/resources_spec.rb
index 020ab9b81..aedc58c7c 100644..100755
--- a/spec/unit/type/resources_spec.rb
+++ b/spec/unit/type/resources_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
resources = Puppet::Type.type(:resources)
diff --git a/spec/unit/type/schedule_spec.rb b/spec/unit/type/schedule_spec.rb
index 59d199812..7599411e4 100755
--- a/spec/unit/type/schedule_spec.rb
+++ b/spec/unit/type/schedule_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
module ScheduleTesting
diff --git a/spec/unit/type/selboolean_spec.rb b/spec/unit/type/selboolean_spec.rb
index 41b254f25..aa495af4a 100755
--- a/spec/unit/type/selboolean_spec.rb
+++ b/spec/unit/type/selboolean_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:selboolean), "when validating attributes" do
[:name, :persistent].each do |param|
diff --git a/spec/unit/type/selmodule_spec.rb b/spec/unit/type/selmodule_spec.rb
index 37453d8ed..c067de01d 100755
--- a/spec/unit/type/selmodule_spec.rb
+++ b/spec/unit/type/selmodule_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:selmodule), "when validating attributes" do
[:name, :selmoduledir, :selmodulepath].each do |param|
diff --git a/spec/unit/type/service_spec.rb b/spec/unit/type/service_spec.rb
index b11c4d7e7..40270e7c8 100755
--- a/spec/unit/type/service_spec.rb
+++ b/spec/unit/type/service_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:service) do
it "should have an :enableable feature that requires the :enable, :disable, and :enabled? methods" do
diff --git a/spec/unit/type/ssh_authorized_key_spec.rb b/spec/unit/type/ssh_authorized_key_spec.rb
index 287fca3ab..a5f167165 100755
--- a/spec/unit/type/ssh_authorized_key_spec.rb
+++ b/spec/unit/type/ssh_authorized_key_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
ssh_authorized_key = Puppet::Type.type(:ssh_authorized_key)
diff --git a/spec/unit/type/sshkey_spec.rb b/spec/unit/type/sshkey_spec.rb
index 8315d7ba9..ba3406976 100644..100755
--- a/spec/unit/type/sshkey_spec.rb
+++ b/spec/unit/type/sshkey_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
sshkey = Puppet::Type.type(:sshkey)
diff --git a/spec/unit/type/stage_spec.rb b/spec/unit/type/stage_spec.rb
index 19922f112..f5fed6c3c 100644..100755
--- a/spec/unit/type/stage_spec.rb
+++ b/spec/unit/type/stage_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type.type(:stage) do
it "should have a 'name' parameter'" do
diff --git a/spec/unit/type/tidy_spec.rb b/spec/unit/type/tidy_spec.rb
index 56bdf6c19..cb030634b 100755
--- a/spec/unit/type/tidy_spec.rb
+++ b/spec/unit/type/tidy_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/file_bucket/dipper'
tidy = Puppet::Type.type(:tidy)
diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb
index 6421e6049..71c9e1857 100755
--- a/spec/unit/type/user_spec.rb
+++ b/spec/unit/type/user_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
user = Puppet::Type.type(:user)
diff --git a/spec/unit/type/vlan_spec.rb b/spec/unit/type/vlan_spec.rb
new file mode 100755
index 000000000..2983a58e9
--- /dev/null
+++ b/spec/unit/type/vlan_spec.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Puppet::Type.type(:vlan) do
+ it "should have a 'name' parameter'" do
+ Puppet::Type.type(:vlan).new(:name => "200")[:name].should == "200"
+ end
+
+ it "should have a 'device_url' parameter'" do
+ Puppet::Type.type(:vlan).new(:name => "200", :device_url => :device)[:device_url].should == :device
+ end
+
+ it "should have an ensure property" do
+ Puppet::Type.type(:vlan).attrtype(:ensure).should == :property
+ end
+
+ it "should have a description property" do
+ Puppet::Type.type(:vlan).attrtype(:description).should == :property
+ end
+
+ describe "when validating attribute values" do
+ before do
+ @provider = stub 'provider', :class => Puppet::Type.type(:vlan).defaultprovider, :clear => nil
+ Puppet::Type.type(:vlan).defaultprovider.stubs(:new).returns(@provider)
+ end
+
+ it "should support :present as a value to :ensure" do
+ Puppet::Type.type(:vlan).new(:name => "200", :ensure => :present)
+ end
+
+ it "should support :absent as a value to :ensure" do
+ Puppet::Type.type(:vlan).new(:name => "200", :ensure => :absent)
+ end
+
+ it "should fail if vlan name is not a number" do
+ lambda { Puppet::Type.type(:vlan).new(:name => "notanumber", :ensure => :present) }.should raise_error
+ end
+ end
+end
diff --git a/spec/unit/type/whit_spec.rb b/spec/unit/type/whit_spec.rb
index 0a3324afa..4d0949900 100644..100755
--- a/spec/unit/type/whit_spec.rb
+++ b/spec/unit/type/whit_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
whit = Puppet::Type.type(:whit).new(:name => "Foo::Bar")
diff --git a/spec/unit/type/zfs_spec.rb b/spec/unit/type/zfs_spec.rb
index 88193fca3..e53c25e02 100755
--- a/spec/unit/type/zfs_spec.rb
+++ b/spec/unit/type/zfs_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
zfs = Puppet::Type.type(:zfs)
diff --git a/spec/unit/type/zone_spec.rb b/spec/unit/type/zone_spec.rb
index e479fb1e9..eb3d33bb0 100755
--- a/spec/unit/type/zone_spec.rb
+++ b/spec/unit/type/zone_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
zone = Puppet::Type.type(:zone)
diff --git a/spec/unit/type/zpool_spec.rb b/spec/unit/type/zpool_spec.rb
index 96e7d548c..9f1800073 100755
--- a/spec/unit/type/zpool_spec.rb
+++ b/spec/unit/type/zpool_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
zpool = Puppet::Type.type(:zpool)
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index f9372fced..ca291c4fa 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Type do
it "should include the Cacher module" do
diff --git a/spec/unit/util/autoload/file_cache_spec.rb b/spec/unit/util/autoload/file_cache_spec.rb
index 5ad820e4c..cdde9bb48 100755
--- a/spec/unit/util/autoload/file_cache_spec.rb
+++ b/spec/unit/util/autoload/file_cache_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/autoload/file_cache'
class FileCacheTester
diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb
index 808885dd7..6d49b57dc 100755
--- a/spec/unit/util/autoload_spec.rb
+++ b/spec/unit/util/autoload_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/autoload'
diff --git a/spec/unit/util/backups_spec.rb b/spec/unit/util/backups_spec.rb
index 3d707a58c..611c19304 100755
--- a/spec/unit/util/backups_spec.rb
+++ b/spec/unit/util/backups_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/backups'
diff --git a/spec/unit/util/cache_accumulator_spec.rb b/spec/unit/util/cache_accumulator_spec.rb
index 4ed9abf5c..9c35cc353 100644..100755
--- a/spec/unit/util/cache_accumulator_spec.rb
+++ b/spec/unit/util/cache_accumulator_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/rails/cache_accumulator'
describe Puppet::Util::CacheAccumulator do
diff --git a/spec/unit/util/cacher_spec.rb b/spec/unit/util/cacher_spec.rb
index 125382e84..2e43b4e20 100755
--- a/spec/unit/util/cacher_spec.rb
+++ b/spec/unit/util/cacher_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/cacher'
diff --git a/spec/unit/util/checksums_spec.rb b/spec/unit/util/checksums_spec.rb
index 954dc650b..146544201 100755
--- a/spec/unit/util/checksums_spec.rb
+++ b/spec/unit/util/checksums_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-9-22.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/util/checksums'
diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb
index a7d261dcf..81612ee5c 100755
--- a/spec/unit/util/command_line_spec.rb
+++ b/spec/unit/util/command_line_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/command_line'
@@ -99,10 +98,11 @@ describe Puppet::Util::CommandLine do
Puppet::Util.expects(:which).with('puppet-whatever').returns(nil)
commandline.expects(:system).never
- commandline.expects(:usage_message).returns("the usage message")
- commandline.expects(:abort).with{|x| x =~ /the usage message/}.raises("stubbed abort")
+ text = Puppet::Face[:help, :current].help
+ commandline.expects(:puts).with { |x| x =~ /Unknown Puppet subcommand/ }
+ commandline.expects(:puts).with text
- lambda{ commandline.execute }.should raise_error('stubbed abort')
+ commandline.execute
end
end
end
@@ -111,6 +111,11 @@ describe Puppet::Util::CommandLine do
@core_apps = %w{describe filebucket kick queue resource agent cert apply doc master}
@command_line = Puppet::Util::CommandLine.new("foo", %w{ client --help whatever.pp }, @tty )
end
+ it "should expose available_subcommands as a class method" do
+ @core_apps.each do |command|
+ @command_line.available_subcommands.should include command
+ end
+ end
it 'should be able to find all existing commands' do
@core_apps.each do |command|
@command_line.available_subcommands.should include command
diff --git a/spec/unit/util/constant_inflector_spec.rb b/spec/unit/util/constant_inflector_spec.rb
index 29574fd5b..cf2e8f892 100755
--- a/spec/unit/util/constant_inflector_spec.rb
+++ b/spec/unit/util/constant_inflector_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-02-12.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/util/constant_inflector'
diff --git a/spec/unit/util/errors_spec.rb b/spec/unit/util/errors_spec.rb
index da1b8b0bd..d51a15ef4 100755
--- a/spec/unit/util/errors_spec.rb
+++ b/spec/unit/util/errors_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/errors'
diff --git a/spec/unit/util/execution_spec.rb b/spec/unit/util/execution_spec.rb
index 312dd3b8e..5b8b8a527 100644..100755
--- a/spec/unit/util/execution_spec.rb
+++ b/spec/unit/util/execution_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Util::Execution do
include Puppet::Util::Execution
diff --git a/spec/unit/util/execution_stub_spec.rb b/spec/unit/util/execution_stub_spec.rb
index 14cf9c67a..34987689c 100644..100755
--- a/spec/unit/util/execution_stub_spec.rb
+++ b/spec/unit/util/execution_stub_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../spec_helper'
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Util::ExecutionStub do
it "should use the provided stub code when 'set' is called" do
diff --git a/spec/unit/util/feature_spec.rb b/spec/unit/util/feature_spec.rb
index 365428752..15375e0b1 100755
--- a/spec/unit/util/feature_spec.rb
+++ b/spec/unit/util/feature_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/feature'
diff --git a/spec/unit/util/file_locking_spec.rb b/spec/unit/util/file_locking_spec.rb
index e9dbe9d7b..261474263 100755
--- a/spec/unit/util/file_locking_spec.rb
+++ b/spec/unit/util/file_locking_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/file_locking'
diff --git a/spec/unit/util/filetype_spec.rb b/spec/unit/util/filetype_spec.rb
index 012631b91..a2c0da660 100644..100755
--- a/spec/unit/util/filetype_spec.rb
+++ b/spec/unit/util/filetype_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/filetype'
diff --git a/spec/unit/util/inline_docs_spec.rb b/spec/unit/util/inline_docs_spec.rb
index 75afb57cb..1d88180b3 100755
--- a/spec/unit/util/inline_docs_spec.rb
+++ b/spec/unit/util/inline_docs_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/inline_docs'
diff --git a/spec/unit/util/ldap/connection_spec.rb b/spec/unit/util/ldap/connection_spec.rb
index 91f008a2e..f97c72d77 100755
--- a/spec/unit/util/ldap/connection_spec.rb
+++ b/spec/unit/util/ldap/connection_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-19.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/util/ldap/connection'
diff --git a/spec/unit/util/ldap/generator_spec.rb b/spec/unit/util/ldap/generator_spec.rb
index 59c05b7c7..b3e664d6b 100755
--- a/spec/unit/util/ldap/generator_spec.rb
+++ b/spec/unit/util/ldap/generator_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-28.
# Copyright (c) 2008. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/util/ldap/generator'
diff --git a/spec/unit/util/ldap/manager_spec.rb b/spec/unit/util/ldap/manager_spec.rb
index e91582c8d..5cce626b5 100755
--- a/spec/unit/util/ldap/manager_spec.rb
+++ b/spec/unit/util/ldap/manager_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-3-19.
# Copyright (c) 2006. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+require 'spec_helper'
require 'puppet/util/ldap/manager'
diff --git a/spec/unit/util/loadedfile_spec.rb b/spec/unit/util/loadedfile_spec.rb
index 92daeb953..dcea53e45 100755
--- a/spec/unit/util/loadedfile_spec.rb
+++ b/spec/unit/util/loadedfile_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'tempfile'
require 'puppet/util/loadedfile'
diff --git a/spec/unit/util/log/destinations_spec.rb b/spec/unit/util/log/destinations_spec.rb
index b84c2ab44..873c5f0c7 100755
--- a/spec/unit/util/log/destinations_spec.rb
+++ b/spec/unit/util/log/destinations_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/log'
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb
index 3c8577493..78411d187 100755
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/log'
diff --git a/spec/unit/util/logging_spec.rb b/spec/unit/util/logging_spec.rb
index 97ffc0b25..6a77e70ef 100755
--- a/spec/unit/util/logging_spec.rb
+++ b/spec/unit/util/logging_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/logging'
@@ -92,4 +91,29 @@ describe Puppet::Util::Logging do
end
end
end
+
+ describe "when sending a deprecation warning" do
+ before do
+ @logger.clear_deprecation_warnings
+ end
+
+ it "should the message with warn" do
+ @logger.expects(:warning).with('foo')
+ @logger.deprecation_warning 'foo'
+ end
+
+ it "should only log each unique message once" do
+ @logger.expects(:warning).with('foo').once
+ 5.times { @logger.deprecation_warning 'foo' }
+ end
+
+ it "should only log the first 100 messages" do
+ (1..100).each { |i|
+ @logger.expects(:warning).with(i).once
+ @logger.deprecation_warning i
+ }
+ @logger.expects(:warning).with(101).never
+ @logger.deprecation_warning 101
+ end
+ end
end
diff --git a/spec/unit/util/metric_spec.rb b/spec/unit/util/metric_spec.rb
index 425812297..07a9e4945 100755
--- a/spec/unit/util/metric_spec.rb
+++ b/spec/unit/util/metric_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/metric'
diff --git a/spec/unit/util/monkey_patches_spec.rb b/spec/unit/util/monkey_patches_spec.rb
index 8bfcd900e..4b609ad09 100644..100755
--- a/spec/unit/util/monkey_patches_spec.rb
+++ b/spec/unit/util/monkey_patches_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/monkey_patches'
@@ -31,3 +30,26 @@ describe "yaml deserialization" do
obj.foo.should == 100
end
end
+
+# In Ruby > 1.8.7 this is a builtin, otherwise we monkey patch the method in
+describe "Array#combination" do
+ it "should fail if wrong number of arguments given" do
+ lambda { [1,2,3].combination() }.should raise_error(ArgumentError, /wrong number/)
+ lambda { [1,2,3].combination(1,2) }.should raise_error(ArgumentError, /wrong number/)
+ end
+
+ it "should return an empty array if combo size than array size or negative" do
+ [1,2,3].combination(4).to_a.should == []
+ [1,2,3].combination(-1).to_a.should == []
+ end
+
+ it "should return an empty array with an empty array if combo size == 0" do
+ [1,2,3].combination(0).to_a.should == [[]]
+ end
+
+ it "should all provide all combinations of size passed in" do
+ [1,2,3,4].combination(1).to_a.should == [[1], [2], [3], [4]]
+ [1,2,3,4].combination(2).to_a.should == [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]
+ [1,2,3,4].combination(3).to_a.should == [[1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]
+ end
+end
diff --git a/spec/unit/util/nagios_maker_spec.rb b/spec/unit/util/nagios_maker_spec.rb
index 20582525d..b61f4fe9d 100755
--- a/spec/unit/util/nagios_maker_spec.rb
+++ b/spec/unit/util/nagios_maker_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2007-11-18.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/util/nagios_maker'
diff --git a/spec/unit/util/network_device/cisco/device_spec.rb b/spec/unit/util/network_device/cisco/device_spec.rb
new file mode 100755
index 000000000..82b0666e6
--- /dev/null
+++ b/spec/unit/util/network_device/cisco/device_spec.rb
@@ -0,0 +1,521 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+
+require 'puppet/util/network_device/cisco/device'
+
+describe Puppet::Util::NetworkDevice::Cisco::Device do
+ before(:each) do
+ @transport = stub_everything 'transport', :is_a? => true, :command => ""
+ @cisco = Puppet::Util::NetworkDevice::Cisco::Device.new("telnet://user:password@localhost:23/")
+ @cisco.transport = @transport
+ end
+
+ describe "when creating the device" do
+ it "should find the enable password from the url" do
+ cisco = Puppet::Util::NetworkDevice::Cisco::Device.new("telnet://user:password@localhost:23/?enable=enable_password")
+ cisco.enable_password.should == "enable_password"
+ end
+
+ it "should find the enable password from the options" do
+ cisco = Puppet::Util::NetworkDevice::Cisco::Device.new("telnet://user:password@localhost:23/?enable=enable_password", :enable_password => "mypass")
+ cisco.enable_password.should == "mypass"
+ end
+ end
+
+ describe "when connecting to the physical device" do
+ it "should connect to the transport" do
+ @transport.expects(:connect)
+ @cisco.command
+ end
+
+ it "should attempt to login" do
+ @cisco.expects(:login)
+ @cisco.command
+ end
+
+ it "should tell the device to not page" do
+ @transport.expects(:command).with("terminal length 0")
+ @cisco.command
+ end
+
+ it "should enter the enable password if returned prompt is not privileged" do
+ @transport.stubs(:command).yields("Switch>").returns("")
+ @cisco.expects(:enable)
+ @cisco.command
+ end
+
+ it "should find device capabilities" do
+ @cisco.expects(:find_capabilities)
+ @cisco.command
+ end
+
+ it "should execute given command" do
+ @transport.expects(:command).with("mycommand")
+ @cisco.command("mycommand")
+ end
+
+ it "should yield to the command block if one is provided" do
+ @transport.expects(:command).with("mycommand")
+ @cisco.command do |c|
+ c.command("mycommand")
+ end
+ end
+
+ it "should close the device transport" do
+ @transport.expects(:close)
+ @cisco.command
+ end
+
+ describe "when login in" do
+ it "should not login if transport handles login" do
+ @transport.expects(:handles_login?).returns(true)
+ @transport.expects(:command).never
+ @transport.expects(:expect).never
+ @cisco.login
+ end
+
+ it "should send username if one has been provided" do
+ @transport.expects(:command).with("user", :prompt => /^Password:/)
+ @cisco.login
+ end
+
+ it "should send password after the username" do
+ @transport.expects(:command).with("user", :prompt => /^Password:/)
+ @transport.expects(:command).with("password")
+ @cisco.login
+ end
+
+ it "should expect the Password: prompt if no user was sent" do
+ @cisco.url.user = ''
+ @transport.expects(:expect).with(/^Password:/)
+ @transport.expects(:command).with("password")
+ @cisco.login
+ end
+ end
+
+ describe "when entering enable password" do
+ it "should raise an error if no enable password has been set" do
+ @cisco.enable_password = nil
+ lambda{ @cisco.enable }.should raise_error
+ end
+
+ it "should send the enable command and expect an enable prompt" do
+ @cisco.enable_password = 'mypass'
+ @transport.expects(:command).with("enable", :prompt => /^Password:/)
+ @cisco.enable
+ end
+
+ it "should send the enable password" do
+ @cisco.enable_password = 'mypass'
+ @transport.stubs(:command).with("enable", :prompt => /^Password:/)
+ @transport.expects(:command).with("mypass")
+ @cisco.enable
+ end
+ end
+ end
+
+ describe "when finding network device capabilities" do
+ it "should try to execute sh vlan brief" do
+ @transport.expects(:command).with("sh vlan brief").returns("")
+ @cisco.find_capabilities
+ end
+
+ it "should detect errors" do
+ @transport.stubs(:command).with("sh vlan brief").returns(<<eos)
+Switch#sh vlan brief
+% Ambiguous command: "sh vlan brief"
+Switch#
+eos
+
+ @cisco.find_capabilities
+ @cisco.should_not be_support_vlan_brief
+ end
+ end
+
+
+ {
+ "Fa 0/1" => "FastEthernet0/1",
+ "Fa0/1" => "FastEthernet0/1",
+ "FastEth 0/1" => "FastEthernet0/1",
+ "Gi1" => "GigEthernet1",
+ "Di9" => "Dialer9",
+ "Ethernet 0/0/1" => "Ethernet0/0/1",
+ "E0" => "Ethernet0",
+ "ATM 0/1.1" => "ATM0/1.1",
+ "VLAN99" => "VLAN99"
+ }.each do |input,expected|
+ it "should canonicalize #{input} to #{expected}" do
+ @cisco.canonalize_ifname(input).should == expected
+ end
+ end
+
+ describe "when updating device vlans" do
+ describe "when removing a vlan" do
+ it "should issue the no vlan command" do
+ @transport.expects(:command).with("no vlan 200")
+ @cisco.update_vlan("200", {:ensure => :present, :name => "200"}, { :ensure=> :absent})
+ end
+ end
+
+ describe "when updating a vlan" do
+ it "should issue the vlan command to enter global vlan modifications" do
+ @transport.expects(:command).with("vlan 200")
+ @cisco.update_vlan("200", {:ensure => :present, :name => "200"}, { :ensure=> :present, :name => "200"})
+ end
+
+ it "should issue the name command to modify the vlan description" do
+ @transport.expects(:command).with("name myvlan")
+ @cisco.update_vlan("200", {:ensure => :present, :name => "200"}, { :ensure=> :present, :name => "200", :description => "myvlan"})
+ end
+ end
+ end
+
+ describe "when parsing interface" do
+
+ it "should parse interface output" do
+ @cisco.expects(:parse_interface).returns({ :ensure => :present })
+
+ @cisco.interface("FastEthernet0/1").should == { :ensure => :present }
+ end
+
+ it "should parse trunking and merge results" do
+ @cisco.stubs(:parse_interface).returns({ :ensure => :present })
+ @cisco.expects(:parse_trunking).returns({ :native_vlan => "100" })
+
+ @cisco.interface("FastEthernet0/1").should == { :ensure => :present, :native_vlan => "100" }
+ end
+
+ it "should return an absent interface if parse_interface returns nothing" do
+ @cisco.stubs(:parse_interface).returns({})
+
+ @cisco.interface("FastEthernet0/1").should == { :ensure => :absent }
+ end
+
+ it "should parse ip address information and merge results" do
+ @cisco.stubs(:parse_interface).returns({ :ensure => :present })
+ @cisco.expects(:parse_interface_config).returns({ :ipaddress => [24,IPAddr.new('192.168.0.24'), nil] })
+
+ @cisco.interface("FastEthernet0/1").should == { :ensure => :present, :ipaddress => [24,IPAddr.new('192.168.0.24'), nil] }
+ end
+
+ it "should parse the sh interface command" do
+ @transport.stubs(:command).with("sh interface FastEthernet0/1").returns(<<eos)
+Switch#sh interfaces FastEthernet 0/1
+FastEthernet0/1 is down, line protocol is down
+ Hardware is Fast Ethernet, address is 00d0.bbe2.19c1 (bia 00d0.bbe2.19c1)
+ MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
+ reliability 255/255, txload 1/255, rxload 1/255
+ Encapsulation ARPA, loopback not set
+ Keepalive not set
+ Auto-duplex , Auto Speed , 100BaseTX/FX
+ ARP type: ARPA, ARP Timeout 04:00:00
+ Last input never, output 5d04h, output hang never
+ Last clearing of "show interface" counters never
+ Queueing strategy: fifo
+ Output queue 0/40, 0 drops; input queue 0/75, 0 drops
+ 5 minute input rate 0 bits/sec, 0 packets/sec
+ 5 minute output rate 0 bits/sec, 0 packets/sec
+ 580 packets input, 54861 bytes
+ Received 6 broadcasts, 0 runts, 0 giants, 0 throttles
+ 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
+ 0 watchdog, 1 multicast
+ 0 input packets with dribble condition detected
+ 845 packets output, 80359 bytes, 0 underruns
+ 0 output errors, 0 collisions, 1 interface resets
+ 0 babbles, 0 late collision, 0 deferred
+ 0 lost carrier, 0 no carrier
+ 0 output buffer failures, 0 output buffers swapped out
+Switch#
+eos
+
+ @cisco.parse_interface("FastEthernet0/1").should == { :ensure => :absent, :duplex => :auto, :speed => :auto }
+ end
+
+ it "should be able to parse the sh vlan brief command output" do
+ @cisco.stubs(:support_vlan_brief?).returns(true)
+ @transport.stubs(:command).with("sh vlan brief").returns(<<eos)
+Switch#sh vlan brief
+VLAN Name Status Ports
+---- -------------------------------- --------- -------------------------------
+1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6,
+ Fa0/7, Fa0/8, Fa0/9, Fa0/10,
+ Fa0/11, Fa0/12, Fa0/13, Fa0/14,
+ Fa0/15, Fa0/16, Fa0/17, Fa0/18,
+ Fa0/23, Fa0/24
+10 VLAN0010 active
+100 management active Fa0/1, Fa0/2
+Switch#
+eos
+
+ @cisco.parse_vlans.should == {"100"=>{:status=>"active", :interfaces=>["FastEthernet0/1", "FastEthernet0/2"], :description=>"management", :name=>"100"}, "1"=>{:status=>"active", :interfaces=>["FastEthernet0/3", "FastEthernet0/4", "FastEthernet0/5", "FastEthernet0/6", "FastEthernet0/7", "FastEthernet0/8", "FastEthernet0/9", "FastEthernet0/10", "FastEthernet0/11", "FastEthernet0/12", "FastEthernet0/13", "FastEthernet0/14", "FastEthernet0/15", "FastEthernet0/16", "FastEthernet0/17", "FastEthernet0/18", "FastEthernet0/23", "FastEthernet0/24"], :description=>"default", :name=>"1"}, "10"=>{:status=>"active", :interfaces=>[], :description=>"VLAN0010", :name=>"10"}}
+ end
+
+ it "should parse trunk switchport information" do
+ @transport.stubs(:command).with("sh interface FastEthernet0/21 switchport").returns(<<eos)
+Switch#sh interfaces FastEthernet 0/21 switchport
+Name: Fa0/21
+Switchport: Enabled
+Administrative mode: trunk
+Operational Mode: trunk
+Administrative Trunking Encapsulation: dot1q
+Operational Trunking Encapsulation: dot1q
+Negotiation of Trunking: Disabled
+Access Mode VLAN: 0 ((Inactive))
+Trunking Native Mode VLAN: 1 (default)
+Trunking VLANs Enabled: ALL
+Trunking VLANs Active: 1,10,100
+Pruning VLANs Enabled: 2-1001
+
+Priority for untagged frames: 0
+Override vlan tag priority: FALSE
+Voice VLAN: none
+Appliance trust: none
+Self Loopback: No
+Switch#
+eos
+
+ @cisco.parse_trunking("FastEthernet0/21").should == { :mode => :trunk, :encapsulation => :dot1q, :allowed_trunk_vlans=>:all, }
+ end
+
+ it "should parse trunk switchport information with allowed vlans" do
+ @transport.stubs(:command).with("sh interface GigabitEthernet 0/1 switchport").returns(<<eos)
+c2960#sh interfaces GigabitEthernet 0/1 switchport
+Name: Gi0/1
+Switchport: Enabled
+Administrative Mode: trunk
+Operational Mode: trunk
+Administrative Trunking Encapsulation: dot1q
+Operational Trunking Encapsulation: dot1q
+Negotiation of Trunking: On
+Access Mode VLAN: 1 (default)
+Trunking Native Mode VLAN: 1 (default)
+Administrative Native VLAN tagging: enabled
+Voice VLAN: none
+Administrative private-vlan host-association: none
+Administrative private-vlan mapping: none
+Administrative private-vlan trunk native VLAN: none
+Administrative private-vlan trunk Native VLAN tagging: enabled
+Administrative private-vlan trunk encapsulation: dot1q
+Administrative private-vlan trunk normal VLANs: none
+Administrative private-vlan trunk associations: none
+Administrative private-vlan trunk mappings: none
+Operational private-vlan: none
+Trunking VLANs Enabled: 1,99
+Pruning VLANs Enabled: 2-1001
+Capture Mode Disabled
+Capture VLANs Allowed: ALL
+
+Protected: false
+Unknown unicast blocked: disabled
+Unknown multicast blocked: disabled
+Appliance trust: none
+c2960#
+eos
+
+ @cisco.parse_trunking("GigabitEthernet 0/1").should == { :mode => :trunk, :encapsulation => :dot1q, :allowed_trunk_vlans=>"1,99", }
+ end
+
+ it "should parse access switchport information" do
+ @transport.stubs(:command).with("sh interface FastEthernet0/1 switchport").returns(<<eos)
+Switch#sh interfaces FastEthernet 0/1 switchport
+Name: Fa0/1
+Switchport: Enabled
+Administrative mode: static access
+Operational Mode: static access
+Administrative Trunking Encapsulation: isl
+Operational Trunking Encapsulation: isl
+Negotiation of Trunking: Disabled
+Access Mode VLAN: 100 (SHDSL)
+Trunking Native Mode VLAN: 1 (default)
+Trunking VLANs Enabled: NONE
+Pruning VLANs Enabled: NONE
+
+Priority for untagged frames: 0
+Override vlan tag priority: FALSE
+Voice VLAN: none
+Appliance trust: none
+Self Loopback: No
+Switch#
+eos
+
+ @cisco.parse_trunking("FastEthernet0/1").should == { :mode => :access, :native_vlan => "100" }
+ end
+
+ it "should parse ip addresses" do
+ @transport.stubs(:command).with("sh running-config interface Vlan 1 | begin interface").returns(<<eos)
+router#sh running-config interface Vlan 1 | begin interface
+interface Vlan1
+ description $ETH-SW-LAUNCH$$INTF-INFO-HWIC 4ESW$$FW_INSIDE$
+ ip address 192.168.0.24 255.255.255.0 secondary
+ ip address 192.168.0.1 255.255.255.0
+ ip access-group 100 in
+ no ip redirects
+ no ip proxy-arp
+ ip nbar protocol-discovery
+ ip dns view-group dow
+ ip nat inside
+ ip virtual-reassembly
+ ip route-cache flow
+ ipv6 address 2001:7A8:71C1::/64 eui-64
+ ipv6 enable
+ ipv6 traffic-filter DENY-ACL6 out
+ ipv6 mtu 1280
+ ipv6 nd prefix 2001:7A8:71C1::/64
+ ipv6 nd ra interval 60
+ ipv6 nd ra lifetime 180
+ ipv6 verify unicast reverse-path
+ ipv6 inspect STD6 out
+end
+
+router#
+eos
+ @cisco.parse_interface_config("Vlan 1").should == {:ipaddress=>[[24, IPAddr.new('192.168.0.24'), 'secondary'],
+ [24, IPAddr.new('192.168.0.1'), nil],
+ [64, IPAddr.new('2001:07a8:71c1::'), "eui-64"]]}
+ end
+
+ it "should parse etherchannel membership" do
+ @transport.stubs(:command).with("sh running-config interface Gi0/17 | begin interface").returns(<<eos)
+c2960#sh running-config interface Gi0/17 | begin interface
+interface GigabitEthernet0/17
+ description member of Po1
+ switchport mode access
+ channel-protocol lacp
+ channel-group 1 mode passive
+ spanning-tree portfast
+ spanning-tree bpduguard enable
+end
+
+c2960#
+eos
+ @cisco.parse_interface_config("Gi0/17").should == {:etherchannel=>"1"}
+ end
+ end
+end
+
+# static access
+# Switch#sh interfaces FastEthernet 0/1 switchport
+# Name: Fa0/1
+# Switchport: Enabled
+# Administrative mode: static access
+# Operational Mode: static access
+# Administrative Trunking Encapsulation: isl
+# Operational Trunking Encapsulation: isl
+# Negotiation of Trunking: Disabled
+# Access Mode VLAN: 100 (SHDSL)
+# Trunking Native Mode VLAN: 1 (default)
+# Trunking VLANs Enabled: NONE
+# Pruning VLANs Enabled: NONE
+#
+# Priority for untagged frames: 0
+# Override vlan tag priority: FALSE
+# Voice VLAN: none
+# Appliance trust: none
+# Self Loopback: No
+# Switch#
+
+# c2960#sh interfaces GigabitEthernet 0/1 switchport
+# Name: Gi0/1
+# Switchport: Enabled
+# Administrative Mode: trunk
+# Operational Mode: trunk
+# Administrative Trunking Encapsulation: dot1q
+# Operational Trunking Encapsulation: dot1q
+# Negotiation of Trunking: On
+# Access Mode VLAN: 1 (default)
+# Trunking Native Mode VLAN: 1 (default)
+# Administrative Native VLAN tagging: enabled
+# Voice VLAN: none
+# Administrative private-vlan host-association: none
+# Administrative private-vlan mapping: none
+# Administrative private-vlan trunk native VLAN: none
+# Administrative private-vlan trunk Native VLAN tagging: enabled
+# Administrative private-vlan trunk encapsulation: dot1q
+# Administrative private-vlan trunk normal VLANs: none
+# Administrative private-vlan trunk associations: none
+# Administrative private-vlan trunk mappings: none
+# Operational private-vlan: none
+# Trunking VLANs Enabled: 1,99
+# Pruning VLANs Enabled: 2-1001
+# Capture Mode Disabled
+# Capture VLANs Allowed: ALL
+#
+# Protected: false
+# Unknown unicast blocked: disabled
+# Unknown multicast blocked: disabled
+# Appliance trust: none
+# c2960#
+
+# c2960#sh interfaces GigabitEthernet 0/2 switchport
+# Name: Gi0/2
+# Switchport: Enabled
+# Administrative Mode: static access
+# Operational Mode: static access
+# Administrative Trunking Encapsulation: dot1q
+# Operational Trunking Encapsulation: native
+# Negotiation of Trunking: Off
+# Access Mode VLAN: 99 (MGMT)
+# Trunking Native Mode VLAN: 1 (default)
+# Administrative Native VLAN tagging: enabled
+# Voice VLAN: none
+# Administrative private-vlan host-association: none
+# Administrative private-vlan mapping: none
+# Administrative private-vlan trunk native VLAN: none
+# Administrative private-vlan trunk Native VLAN tagging: enabled
+# Administrative private-vlan trunk encapsulation: dot1q
+# Administrative private-vlan trunk normal VLANs: none
+# Administrative private-vlan trunk associations: none
+# Administrative private-vlan trunk mappings: none
+# Operational private-vlan: none
+# Trunking VLANs Enabled: ALL
+# Pruning VLANs Enabled: 2-1001
+# Capture Mode Disabled
+# Capture VLANs Allowed: ALL
+#
+# Protected: false
+# Unknown unicast blocked: disabled
+# Unknown multicast blocked: disabled
+# Appliance trust: none
+# c2960#
+
+# c877#sh interfaces FastEthernet 1 switchport
+# Name: Fa1
+# Switchport: Enabled
+# Administrative Mode: trunk
+# Operational Mode: trunk
+# Administrative Trunking Encapsulation: dot1q
+# Operational Trunking Encapsulation: dot1q
+# Negotiation of Trunking: Disabled
+# Access Mode VLAN: 0 ((Inactive))
+# Trunking Native Mode VLAN: 1 (default)
+# Trunking VLANs Enabled: ALL
+# Trunking VLANs Active: 1
+# Protected: false
+# Priority for untagged frames: 0
+# Override vlan tag priority: FALSE
+# Voice VLAN: none
+# Appliance trust: none
+
+
+# c2960#sh etherchannel summary
+# Flags: D - down P - bundled in port-channel
+# I - stand-alone s - suspended
+# H - Hot-standby (LACP only)
+# R - Layer3 S - Layer2
+# U - in use f - failed to allocate aggregator
+#
+# M - not in use, minimum links not met
+# u - unsuitable for bundling
+# w - waiting to be aggregated
+# d - default port
+#
+#
+# Number of channel-groups in use: 1
+# Number of aggregators: 1
+#
+# Group Port-channel Protocol Ports
+# ------+-------------+-----------+-----------------------------------------------
+# 1 Po1(SU) LACP Gi0/17(P) Gi0/18(P)
+#
+# c2960#
diff --git a/spec/unit/util/network_device/cisco/interface_spec.rb b/spec/unit/util/network_device/cisco/interface_spec.rb
new file mode 100755
index 000000000..24217750c
--- /dev/null
+++ b/spec/unit/util/network_device/cisco/interface_spec.rb
@@ -0,0 +1,89 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+
+require 'puppet/util/network_device'
+require 'puppet/util/network_device/cisco/interface'
+
+describe Puppet::Util::NetworkDevice::Cisco::Interface do
+ before(:each) do
+ @transport = stub_everything 'transport'
+ @interface = Puppet::Util::NetworkDevice::Cisco::Interface.new("FastEthernet0/1",@transport)
+ end
+
+ it "should include IPCalc" do
+ @interface.class.include?(Puppet::Util::NetworkDevice::IPCalc)
+ end
+
+ describe "when updating the physical device" do
+ it "should enter global configuration mode" do
+ @transport.expects(:command).with("conf t")
+ @interface.update
+ end
+
+ it "should enter interface configuration mode" do
+ @transport.expects(:command).with("interface FastEthernet0/1")
+ @interface.update
+ end
+
+ it "should 'execute' all differing properties" do
+ @interface.expects(:execute).with(:description, "b")
+ @interface.expects(:execute).with(:mode, :access).never
+ @interface.update({ :description => "a", :mode => :access }, { :description => "b", :mode => :access })
+ end
+
+ it "should execute in cisco ios defined order" do
+ speed = states('speed').starts_as('notset')
+ @interface.expects(:execute).with(:speed, :auto).then(speed.is('set'))
+ @interface.expects(:execute).with(:duplex, :auto).when(speed.is('set'))
+ @interface.update({ :duplex => :half, :speed => "10" }, { :duplex => :auto, :speed => :auto })
+ end
+
+ it "should execute absent properties with a no prefix" do
+ @interface.expects(:execute).with(:description, "a", "no ")
+ @interface.update({ :description => "a"}, { })
+ end
+
+ it "should exit twice" do
+ @transport.expects(:command).with("exit").twice
+ @interface.update
+ end
+ end
+
+ describe "when executing commands" do
+ it "should execute string commands directly" do
+ @transport.expects(:command).with("speed auto")
+ @interface.execute(:speed, :auto)
+ end
+
+ it "should execute string commands with the given prefix" do
+ @transport.expects(:command).with("no speed auto")
+ @interface.execute(:speed, :auto, "no ")
+ end
+
+ it "should stop at executing the first command that works for array" do
+ @transport.expects(:command).with("channel-group 1").yields("% Invalid command")
+ @transport.expects(:command).with("port group 1")
+ @interface.execute(:etherchannel, "1")
+ end
+
+ it "should execute the block for block commands" do
+ @transport.expects(:command).with("ip address 192.168.0.1 255.255.255.0")
+ @interface.execute(:ipaddress, [[24, IPAddr.new('192.168.0.1'), nil]])
+ end
+
+ it "should execute the block for block commands" do
+ @transport.expects(:command).with("ipv6 address fe08::/76 link-local")
+ @interface.execute(:ipaddress, [[76, IPAddr.new('fe08::'), 'link-local']])
+ end
+
+ end
+
+ describe "when sending commands to the device" do
+ it "should detect errors" do
+ Puppet.expects(:err)
+ @transport.stubs(:command).yields("% Invalid Command")
+ @interface.command("sh ver")
+ end
+ end
+end
diff --git a/spec/unit/util/network_device/ipcalc_spec.rb b/spec/unit/util/network_device/ipcalc_spec.rb
new file mode 100755
index 000000000..0418c6a84
--- /dev/null
+++ b/spec/unit/util/network_device/ipcalc_spec.rb
@@ -0,0 +1,63 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+require 'puppet/util/network_device/ipcalc'
+
+describe Puppet::Util::NetworkDevice::IPCalc do
+ class TestIPCalc
+ include Puppet::Util::NetworkDevice::IPCalc
+ end
+
+ before(:each) do
+ @ipcalc = TestIPCalc.new
+ end
+
+ describe "when parsing ip/prefix" do
+ it "should parse ipv4 without prefixes" do
+ @ipcalc.parse('127.0.0.1').should == [32,IPAddr.new('127.0.0.1')]
+ end
+
+ it "should parse ipv4 with prefixes" do
+ @ipcalc.parse('127.0.1.2/8').should == [8,IPAddr.new('127.0.1.2')]
+ end
+
+ it "should parse ipv6 without prefixes" do
+ @ipcalc.parse('FE80::21A:2FFF:FE30:ECF0').should == [128,IPAddr.new('FE80::21A:2FFF:FE30:ECF0')]
+ end
+
+ it "should parse ipv6 with prefixes" do
+ @ipcalc.parse('FE80::21A:2FFF:FE30:ECF0/56').should == [56,IPAddr.new('FE80::21A:2FFF:FE30:ECF0')]
+ end
+ end
+
+ describe "when building netmask" do
+ it "should produce the correct ipv4 netmask from prefix length" do
+ @ipcalc.netmask(Socket::AF_INET, 27).should == IPAddr.new('255.255.255.224')
+ end
+
+ it "should produce the correct ipv6 netmask from prefix length" do
+ @ipcalc.netmask(Socket::AF_INET6, 56).should == IPAddr.new('ffff:ffff:ffff:ff00::0')
+ end
+ end
+
+ describe "when building wildmask" do
+ it "should produce the correct ipv4 wildmask from prefix length" do
+ @ipcalc.wildmask(Socket::AF_INET, 27).should == IPAddr.new('0.0.0.31')
+ end
+
+ it "should produce the correct ipv6 wildmask from prefix length" do
+ @ipcalc.wildmask(Socket::AF_INET6, 126).should == IPAddr.new('::3')
+ end
+ end
+
+ describe "when computing prefix length from netmask" do
+ it "should produce the correct ipv4 prefix length" do
+ @ipcalc.prefix_length(IPAddr.new('255.255.255.224')).should == 27
+ end
+
+ it "should produce the correct ipv6 prefix length" do
+ @ipcalc.prefix_length(IPAddr.new('fffe::0')).should == 15
+ end
+ end
+end
diff --git a/spec/unit/util/network_device/transport/base_spec.rb b/spec/unit/util/network_device/transport/base_spec.rb
new file mode 100755
index 000000000..c186d72e5
--- /dev/null
+++ b/spec/unit/util/network_device/transport/base_spec.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+
+require 'puppet/util/network_device/transport/base'
+
+describe Puppet::Util::NetworkDevice::Transport::Base do
+ class TestTransport < Puppet::Util::NetworkDevice::Transport::Base
+ end
+
+ before(:each) do
+ @transport = TestTransport.new
+ end
+
+ describe "when sending commands" do
+ it "should send the command to the telnet session" do
+ @transport.expects(:send).with("line")
+ @transport.command("line")
+ end
+
+ it "should expect an output matching the given prompt" do
+ @transport.expects(:expect).with(/prompt/)
+ @transport.command("line", :prompt => /prompt/)
+ end
+
+ it "should expect an output matching the default prompt" do
+ @transport.default_prompt = /defprompt/
+ @transport.expects(:expect).with(/defprompt/)
+ @transport.command("line")
+ end
+
+ it "should yield telnet output to the given block" do
+ @transport.expects(:expect).yields("output")
+ @transport.command("line") { |out| out.should == "output" }
+ end
+
+ it "should return telnet output to the caller" do
+ @transport.expects(:expect).returns("output")
+ @transport.command("line").should == "output"
+ end
+ end
+end
diff --git a/spec/unit/util/network_device/transport/ssh_spec.rb b/spec/unit/util/network_device/transport/ssh_spec.rb
new file mode 100755
index 000000000..0e91ed9f9
--- /dev/null
+++ b/spec/unit/util/network_device/transport/ssh_spec.rb
@@ -0,0 +1,211 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+
+require 'puppet/util/network_device/transport/ssh'
+
+describe Puppet::Util::NetworkDevice::Transport::Ssh, :if => Puppet.features.ssh? do
+
+ before(:each) do
+ @transport = Puppet::Util::NetworkDevice::Transport::Ssh.new()
+ end
+
+ it "should handle login through the transport" do
+ @transport.should be_handles_login
+ end
+
+ it "should connect to the given host and port" do
+ Net::SSH.expects(:start).with { |host, user, args| host == "localhost" && args[:port] == 22 }.returns stub_everything
+ @transport.host = "localhost"
+ @transport.port = 22
+
+ @transport.connect
+ end
+
+ it "should connect using the given username and password" do
+ Net::SSH.expects(:start).with { |host, user, args| user == "user" && args[:password] == "pass" }.returns stub_everything
+ @transport.user = "user"
+ @transport.password = "pass"
+
+ @transport.connect
+ end
+
+ describe "when connected" do
+ before(:each) do
+ @ssh = stub_everything 'ssh'
+ @channel = stub_everything 'channel'
+ Net::SSH.stubs(:start).returns @ssh
+ @ssh.stubs(:open_channel).yields(@channel)
+ @transport.stubs(:expect)
+ end
+
+ it "should open a channel" do
+ @ssh.expects(:open_channel)
+
+ @transport.connect
+ end
+
+ it "should request a pty" do
+ @channel.expects(:request_pty)
+
+ @transport.connect
+ end
+
+ it "should create a shell channel" do
+ @channel.expects(:send_channel_request).with("shell")
+ @transport.connect
+ end
+
+ it "should raise an error if shell channel creation fails" do
+ @channel.expects(:send_channel_request).with("shell").yields(@channel, false)
+ lambda { @transport.connect }.should raise_error
+ end
+
+ it "should register an on_data and on_extended_data callback" do
+ @channel.expects(:send_channel_request).with("shell").yields(@channel, true)
+ @channel.expects(:on_data)
+ @channel.expects(:on_extended_data)
+ @transport.connect
+ end
+
+ it "should accumulate data to the buffer on data" do
+ @channel.expects(:send_channel_request).with("shell").yields(@channel, true)
+ @channel.expects(:on_data).yields(@channel, "data")
+
+ @transport.connect
+ @transport.buf.should == "data"
+ end
+
+ it "should accumulate data to the buffer on extended data" do
+ @channel.expects(:send_channel_request).with("shell").yields(@channel, true)
+ @channel.expects(:on_extended_data).yields(@channel, 1, "data")
+
+ @transport.connect
+ @transport.buf.should == "data"
+ end
+
+ it "should mark eof on close" do
+ @channel.expects(:send_channel_request).with("shell").yields(@channel, true)
+ @channel.expects(:on_close).yields(@channel)
+
+ @transport.connect
+ @transport.should be_eof
+ end
+
+ it "should expect output to conform to the default prompt" do
+ @channel.expects(:send_channel_request).with("shell").yields(@channel, true)
+ @transport.expects(:default_prompt).returns("prompt")
+ @transport.expects(:expect).with("prompt")
+ @transport.connect
+ end
+
+ it "should start the ssh loop" do
+ @ssh.expects(:loop)
+ @transport.connect
+ end
+ end
+
+ describe "when closing" do
+ before(:each) do
+ @ssh = stub_everything 'ssh'
+ @channel = stub_everything 'channel'
+ Net::SSH.stubs(:start).returns @ssh
+ @ssh.stubs(:open_channel).yields(@channel)
+ @channel.stubs(:send_channel_request).with("shell").yields(@channel, true)
+ @transport.stubs(:expect)
+ @transport.connect
+ end
+
+ it "should close the channel" do
+ @channel.expects(:close)
+ @transport.close
+ end
+
+ it "should close the ssh session" do
+ @ssh.expects(:close)
+ @transport.close
+ end
+ end
+
+ describe "when sending commands" do
+ before(:each) do
+ @ssh = stub_everything 'ssh'
+ @channel = stub_everything 'channel'
+ Net::SSH.stubs(:start).returns @ssh
+ @ssh.stubs(:open_channel).yields(@channel)
+ @channel.stubs(:send_channel_request).with("shell").yields(@channel, true)
+ @transport.stubs(:expect)
+ @transport.connect
+ end
+
+ it "should send data to the ssh channel" do
+ @channel.expects(:send_data).with("data\n")
+ @transport.command("data")
+ end
+
+ it "should expect the default prompt afterward" do
+ @transport.expects(:default_prompt).returns("prompt")
+ @transport.expects(:expect).with("prompt")
+ @transport.command("data")
+ end
+
+ it "should expect the given prompt" do
+ @transport.expects(:expect).with("myprompt")
+ @transport.command("data", :prompt => "myprompt")
+ end
+
+ it "should yield the buffer output to given block" do
+ @transport.expects(:expect).yields("output")
+ @transport.command("data") do |out|
+ out.should == "output"
+ end
+ end
+
+ it "should return buffer output" do
+ @transport.expects(:expect).returns("output")
+ @transport.command("data").should == "output"
+ end
+ end
+
+ describe "when expecting output" do
+ before(:each) do
+ @connection = stub_everything 'connection'
+ @socket = stub_everything 'socket'
+ transport = stub 'transport', :socket => @socket
+ @ssh = stub_everything 'ssh', :transport => transport
+ @channel = stub_everything 'channel', :connection => @connection
+ @transport.ssh = @ssh
+ @transport.channel = @channel
+ end
+
+ it "should process the ssh event loop" do
+ IO.stubs(:select)
+ @transport.buf = "output"
+ @transport.expects(:process_ssh)
+ @transport.expect(/output/)
+ end
+
+ it "should return the output" do
+ IO.stubs(:select)
+ @transport.buf = "output"
+ @transport.stubs(:process_ssh)
+ @transport.expect(/output/).should == "output"
+ end
+
+ it "should return the output" do
+ IO.stubs(:select)
+ @transport.buf = "output"
+ @transport.stubs(:process_ssh)
+ @transport.expect(/output/).should == "output"
+ end
+
+ describe "when processing the ssh loop" do
+ it "should advance one tick in the ssh event loop and exit on eof" do
+ @transport.buf = ''
+ @connection.expects(:process).then.raises(EOFError)
+ @transport.process_ssh
+ end
+ end
+ end
+
+end
diff --git a/spec/unit/util/network_device/transport/telnet_spec.rb b/spec/unit/util/network_device/transport/telnet_spec.rb
new file mode 100755
index 000000000..7528e0740
--- /dev/null
+++ b/spec/unit/util/network_device/transport/telnet_spec.rb
@@ -0,0 +1,76 @@
+#!/usr/bin/env rspec
+
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+
+require 'puppet/util/network_device/transport/telnet'
+
+describe Puppet::Util::NetworkDevice::Transport::Telnet do
+
+ before(:each) do
+ @transport = Puppet::Util::NetworkDevice::Transport::Telnet.new()
+ end
+
+ it "should not handle login through the transport" do
+ @transport.should_not be_handles_login
+ end
+
+ it "should connect to the given host and port" do
+ Net::Telnet.expects(:new).with { |args| args["Host"] == "localhost" && args["Port"] == 23 }.returns stub_everything
+ @transport.host = "localhost"
+ @transport.port = 23
+
+ @transport.connect
+ end
+
+ it "should connect and specify the default prompt" do
+ @transport.default_prompt = "prompt"
+ Net::Telnet.expects(:new).with { |args| args["Prompt"] == "prompt" }.returns stub_everything
+ @transport.host = "localhost"
+ @transport.port = 23
+
+ @transport.connect
+ end
+
+ describe "when connected" do
+ before(:each) do
+ @telnet = stub_everything 'telnet'
+ Net::Telnet.stubs(:new).returns(@telnet)
+ @transport.connect
+ end
+
+ it "should send line to the telnet session" do
+ @telnet.expects(:puts).with("line")
+ @transport.send("line")
+ end
+
+ describe "when expecting output" do
+ it "should waitfor output on the telnet session" do
+ @telnet.expects(:waitfor).with(/regex/)
+ @transport.expect(/regex/)
+ end
+
+ it "should return telnet session output" do
+ @telnet.expects(:waitfor).returns("output")
+ @transport.expect(/regex/).should == "output"
+ end
+
+ it "should yield telnet session output to the given block" do
+ @telnet.expects(:waitfor).yields("output")
+ @transport.expect(/regex/) { |out| out.should == "output" }
+ end
+ end
+ end
+
+ describe "when closing" do
+ before(:each) do
+ @telnet = stub_everything 'telnet'
+ Net::Telnet.stubs(:new).returns(@telnet)
+ @transport.connect
+ end
+
+ it "should close the telnet session" do
+ @telnet.expects(:close)
+ @transport.close
+ end
+ end
+end
diff --git a/spec/unit/util/package_spec.rb b/spec/unit/util/package_spec.rb
index e72a7ae91..78c114afc 100644..100755
--- a/spec/unit/util/package_spec.rb
+++ b/spec/unit/util/package_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/package'
diff --git a/spec/unit/util/posix_spec.rb b/spec/unit/util/posix_spec.rb
index 6d7351220..db7c5c3a7 100755
--- a/spec/unit/util/posix_spec.rb
+++ b/spec/unit/util/posix_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/posix'
diff --git a/spec/unit/util/pson_spec.rb b/spec/unit/util/pson_spec.rb
index 08758ee38..63d085a66 100755
--- a/spec/unit/util/pson_spec.rb
+++ b/spec/unit/util/pson_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/pson'
diff --git a/spec/unit/util/queue/stomp_spec.rb b/spec/unit/util/queue/stomp_spec.rb
index a11d5324e..f67189cf5 100755
--- a/spec/unit/util/queue/stomp_spec.rb
+++ b/spec/unit/util/queue/stomp_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/queue'
describe Puppet::Util::Queue, :if => Puppet.features.stomp? do
diff --git a/spec/unit/util/queue_spec.rb b/spec/unit/util/queue_spec.rb
index d356fd7bb..59ea57d9b 100755
--- a/spec/unit/util/queue_spec.rb
+++ b/spec/unit/util/queue_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/queue'
require 'spec/mocks'
diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb
index f118dc99b..c7f99051f 100755
--- a/spec/unit/util/rdoc/parser_spec.rb
+++ b/spec/unit/util/rdoc/parser_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/resource/type_collection'
require 'puppet/util/rdoc/parser'
diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb
index 3b5248528..067b5b8a7 100755
--- a/spec/unit/util/rdoc_spec.rb
+++ b/spec/unit/util/rdoc_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/rdoc'
require 'rdoc/rdoc'
diff --git a/spec/unit/util/reference_serializer_spec.rb b/spec/unit/util/reference_serializer_spec.rb
index f72715ed6..de53ab9bb 100644..100755
--- a/spec/unit/util/reference_serializer_spec.rb
+++ b/spec/unit/util/reference_serializer_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/rails/reference_serializer'
class SerializeTester
diff --git a/spec/unit/util/resource_template_spec.rb b/spec/unit/util/resource_template_spec.rb
index e823a9ff4..4f7cafdb7 100755
--- a/spec/unit/util/resource_template_spec.rb
+++ b/spec/unit/util/resource_template_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/resource_template'
diff --git a/spec/unit/util/run_mode_spec.rb b/spec/unit/util/run_mode_spec.rb
index 1956973ea..c8d2b31f6 100644..100755
--- a/spec/unit/util/run_mode_spec.rb
+++ b/spec/unit/util/run_mode_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Util::RunMode do
before do
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index c18be0c2f..0eaf43cbb 100755
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/selinux'
include Puppet::Util::SELinux
diff --git a/spec/unit/util/settings/file_setting_spec.rb b/spec/unit/util/settings/file_setting_spec.rb
index a2049e2ad..734b41f3a 100755
--- a/spec/unit/util/settings/file_setting_spec.rb
+++ b/spec/unit/util/settings/file_setting_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/settings'
require 'puppet/util/settings/file_setting'
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 2ab31c294..aa50c8f3a 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Util::Settings do
describe "when specifying defaults" do
diff --git a/spec/unit/util/storage_spec.rb b/spec/unit/util/storage_spec.rb
index 5359f746f..90c11aa69 100755
--- a/spec/unit/util/storage_spec.rb
+++ b/spec/unit/util/storage_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'yaml'
require 'puppet/util/storage'
diff --git a/spec/unit/util/tagging_spec.rb b/spec/unit/util/tagging_spec.rb
index 5231be2eb..018871bef 100755
--- a/spec/unit/util/tagging_spec.rb
+++ b/spec/unit/util/tagging_spec.rb
@@ -1,9 +1,9 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rspec
#
# Created by Luke Kanies on 2008-01-19.
# Copyright (c) 2007. All rights reserved.
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'puppet/util/tagging'
diff --git a/spec/unit/util/user_attr_spec.rb b/spec/unit/util/user_attr_spec.rb
index 5acdaee58..2d6ba8b5a 100644..100755
--- a/spec/unit/util/user_attr_spec.rb
+++ b/spec/unit/util/user_attr_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/user_attr'
diff --git a/spec/unit/util/warnings_spec.rb b/spec/unit/util/warnings_spec.rb
index a3460bccf..cc2c44711 100755
--- a/spec/unit/util/warnings_spec.rb
+++ b/spec/unit/util/warnings_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
describe Puppet::Util::Warnings do
before(:all) do
diff --git a/spec/unit/util/zaml_spec.rb b/spec/unit/util/zaml_spec.rb
index 804aa8e58..d77cf99d2 100755
--- a/spec/unit/util/zaml_spec.rb
+++ b/spec/unit/util/zaml_spec.rb
@@ -1,6 +1,5 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+#!/usr/bin/env rspec
+require 'spec_helper'
require 'puppet/util/monkey_patches'