Module: ChefSpec

Defined in:
lib/chefspec.rb,
lib/chefspec/api.rb,
lib/chefspec/util.rb,
lib/chefspec/cacher.rb,
lib/chefspec/errors.rb,
lib/chefspec/runner.rb,
lib/chefspec/version.rb,
lib/chefspec/api/core.rb,
lib/chefspec/api/link.rb,
lib/chefspec/api/user.rb,
lib/chefspec/coverage.rb,
lib/chefspec/matchers.rb,
lib/chefspec/renderer.rb,
lib/chefspec/api/stubs.rb,
lib/chefspec/berkshelf.rb,
lib/chefspec/formatter.rb,
lib/chefspec/librarian.rb,
lib/chefspec/api/reboot.rb,
lib/chefspec/policyfile.rb,
lib/chefspec/stubs/stub.rb,
lib/chefspec/solo_runner.rb,
lib/chefspec/zero_server.rb,
lib/chefspec/deprecations.rb,
lib/chefspec/api/described.rb,
lib/chefspec/api/stubs_for.rb,
lib/chefspec/server_runner.rb,
lib/chefspec/api/do_nothing.rb,
lib/chefspec/server_methods.rb,
lib/chefspec/stubs/registry.rb,
lib/chefspec/api/render_file.rb,
lib/chefspec/api/state_attrs.rb,
lib/chefspec/coverage/filters.rb,
lib/chefspec/mixins/normalize.rb,
lib/chefspec/api/notifications.rb,
lib/chefspec/api/subscriptions.rb,
lib/chefspec/stubs/search_stub.rb,
lib/chefspec/api/include_recipe.rb,
lib/chefspec/stubs/command_stub.rb,
lib/chefspec/stubs/data_bag_stub.rb,
lib/chefspec/file_cache_path_proxy.rb,
lib/chefspec/stubs/search_registry.rb,
lib/chefspec/api/include_any_recipe.rb,
lib/chefspec/stubs/command_registry.rb,
lib/chefspec/stubs/data_bag_registry.rb,
lib/chefspec/stubs/data_bag_item_stub.rb,
lib/chefspec/stubs/data_bag_item_registry.rb,
lib/chefspec/expect_exception.rb

Defined Under Namespace

Modules: API, Cacher, Error, Extensions, Matchers, Normalize, ServerMethods, Stubs, Util Classes: Berkshelf, ChefFormatter, Coverage, ExpectException, FileCachePathProxy, Librarian, Policyfile, Renderer, Server, ServerRunner, SoloRunner, ZeroServer

Constant Summary collapse

Runner =

As we start to migrate back to only SoloRunner, include this alias for now.

Since:

  • 7.3

SoloRunner
VERSION =
"9.3.3".freeze

Class Method Summary collapse

Class Method Details

.define_matcher(resource_name) ⇒ self

Defines a new runner method on the Chef runner.

Parameters:

  • resource_name (Symbol)

    the name of the resource to define a method

Returns:

  • (self)


12
13
14
15
16
17
18
# File 'lib/chefspec.rb', line 12

def define_matcher(resource_name)
  matchers[resource_name.to_sym] = Proc.new do |identity|
    find_resource(resource_name, identity)
  end

  self
end

.matchersHash<String, Proc>

The list of custom defined matchers.

Returns:

  • (Hash<String, Proc>)


39
40
41
# File 'lib/chefspec.rb', line 39

def matchers
  @matchers ||= {}
end

.rootPathname

The source root of the ChefSpec gem. This is useful when requiring files that are relative to the root of the project.

Returns:

  • (Pathname)


27
28
29
# File 'lib/chefspec.rb', line 27

def root
  @root ||= Pathname.new(File.expand_path("..", __dir__))
end