Module: BoltSpec::BoltContext
- Included in:
- Plans
- Defined in:
- lib/bolt_spec/bolt_context.rb
Instance Method Summary collapse
-
#allow_out_message ⇒ Object
(also: #allow_any_out_message)
Does this belong here?.
-
#config ⇒ Object
Override in your tests.
-
#config_data ⇒ Object
Overrides configuration for tests.
- #executor ⇒ Object
- #expect_out_message ⇒ Object
- #in_bolt_context(&block) ⇒ Object
- #inventory ⇒ Object
-
#inventory_data ⇒ Object
Overrides inventory for tests.
-
#modulepath ⇒ Object
Override in your tests if needed.
- #pal ⇒ Object
- #plugins ⇒ Object
- #setup ⇒ Object
Instance Method Details
#allow_out_message ⇒ Object Also known as: allow_any_out_message
Does this belong here?
185 186 187 |
# File 'lib/bolt_spec/bolt_context.rb', line 185 def executor..add_stub end |
#config ⇒ Object
Override in your tests
148 149 150 151 152 153 154 |
# File 'lib/bolt_spec/bolt_context.rb', line 148 def config @config ||= begin conf = Bolt::Config.new(Bolt::Project.default_project, config_data) conf.modulepath = [modulepath].flatten conf end end |
#config_data ⇒ Object
Overrides configuration for tests.
139 140 141 |
# File 'lib/bolt_spec/bolt_context.rb', line 139 def config_data {} end |
#executor ⇒ Object
129 130 131 |
# File 'lib/bolt_spec/bolt_context.rb', line 129 def executor @executor ||= BoltSpec::Plans::MockExecutor.new(modulepath) end |
#expect_out_message ⇒ Object
190 191 192 |
# File 'lib/bolt_spec/bolt_context.rb', line 190 def .expect_call end |
#in_bolt_context(&block) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/bolt_spec/bolt_context.rb', line 101 def in_bolt_context(&block) setup old_modpath = RSpec.configuration.module_path old_tasks = Puppet[:tasks] # Set the things Puppet[:tasks] = true RSpec.configuration.module_path = [modulepath, Bolt::Config::Modulepath::BOLTLIB_PATH].join(File::PATH_SEPARATOR) opts = { bolt_executor: executor, bolt_inventory: inventory, bolt_pdb_client: nil, apply_executor: nil } Puppet.override(opts, &block) # Unset the things RSpec.configuration.module_path = old_modpath Puppet[:tasks] = old_tasks end |
#inventory ⇒ Object
143 144 145 |
# File 'lib/bolt_spec/bolt_context.rb', line 143 def inventory @inventory ||= Bolt::Inventory.create_version(inventory_data, config.transport, config.transports, plugins) end |
#inventory_data ⇒ Object
Overrides inventory for tests.
134 135 136 |
# File 'lib/bolt_spec/bolt_context.rb', line 134 def inventory_data {} end |
#modulepath ⇒ Object
Override in your tests if needed
123 124 125 126 127 |
# File 'lib/bolt_spec/bolt_context.rb', line 123 def modulepath [RSpec.configuration.module_path] rescue NoMethodError raise "RSpec.configuration.module_path not defined set up rspec puppet or define modulepath for this test" end |
#pal ⇒ Object
160 161 162 163 164 |
# File 'lib/bolt_spec/bolt_context.rb', line 160 def pal @pal ||= Bolt::PAL.new(Bolt::Config::Modulepath.new(config.modulepath), config.hiera_config, config.project.resource_types) end |
#plugins ⇒ Object
156 157 158 |
# File 'lib/bolt_spec/bolt_context.rb', line 156 def plugins @plugins ||= Bolt::Plugin.setup(config, pal) end |
#setup ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/bolt_spec/bolt_context.rb', line 93 def setup unless @loaded # This is slow so don't do it until we have to Bolt::PAL.load_puppet @loaded = true end end |