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/macros.rb,
lib/chefspec/version.rb,
lib/chefspec/coverage.rb,
lib/chefspec/matchers.rb,
lib/chefspec/renderer.rb,
lib/chefspec/berkshelf.rb,
lib/chefspec/formatter.rb,
lib/chefspec/librarian.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/server_runner.rb,
lib/chefspec/server_methods.rb,
lib/chefspec/stubs/registry.rb,
lib/chefspec/coverage/filters.rb,
lib/chefspec/mixins/normalize.rb,
lib/chefspec/stubs/search_stub.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/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, Macros, Matchers, Normalize, ServerMethods, Stubs, Util Classes: Berkshelf, ChefFormatter, Coverage, ExpectException, FileCachePathProxy, Librarian, Policyfile, Renderer, Runner, Server, ServerRunner, SoloRunner, ZeroServer

Constant Summary collapse

VERSION =
'7.1.1'

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('../../', __FILE__))
end