Class: ChefSpec::ServerRunner
- Inherits:
-
SoloRunner
- Object
- SoloRunner
- ChefSpec::ServerRunner
- Includes:
- ServerMethods
- Defined in:
- lib/chefspec/server_runner.rb
Instance Attribute Summary
Attributes inherited from SoloRunner
Instance Method Summary collapse
- #converge(*recipe_names) ⇒ Object
-
#initialize(options = {}) {|node, _self| ... } ⇒ ServerRunner
constructor
A new instance of ServerRunner.
Methods included from ServerMethods
#client, #clients, #create_client, #create_data_bag, #create_environment, #create_node, #create_role, #data, #data_bag, entity, #environment, #environments, #get, #has_client?, #has_data_bag?, #has_environment?, #has_node?, #has_role?, #load_data, #node, #nodes, #role, #roles, #server
Methods inherited from SoloRunner
#compiling?, converge, #dry_run?, #find_resource, #find_resources, #inspect, #method_missing, #node, #resource_collection, #respond_to_missing?, #step_into?, #to_s
Methods included from Normalize
Constructor Details
#initialize(options = {}) {|node, _self| ... } ⇒ ServerRunner
Returns a new instance of ServerRunner.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/chefspec/server_runner.rb', line 14 def initialize( = {}) # Unlike the SoloRunner, the file_cache_path needs to remain consistent # for every Chef run or else the Chef client tries to loads the same # cookbook multiple times and will encounter deprecated logic when # creating LWRPs. It also slows down the entire process. [:file_cache_path] ||= RSpec.configuration.file_cache_path || ChefSpec::FileCachePathProxy.instance.file_cache_path # Call super, but do not pass in the block because we want to customize # our yielding. super(, &nil) Chef::Config[:client_key] = client_key Chef::Config[:client_name] = 'chefspec' Chef::Config[:node_name] = 'chefspec' Chef::Config[:solo] = false Chef::Config[:solo_legacy_mode] = false Chef::Config[:chef_server_url] = server.url Chef::Config[:http_retry_count] = 0 # Unlike the SoloRunner, the node AND server object are yielded for # customization yield node, self if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ChefSpec::SoloRunner
Instance Method Details
#converge(*recipe_names) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/chefspec/server_runner.rb', line 41 def converge(*recipe_names) ChefSpec::ZeroServer.upload_cookbooks! super do yield if block_given? # Save the node back to the server for searching purposes client.register node.save end end |