Sha256: 1f3d22d7bd626d566a7e4038d0d8310d6cd15a8a60cd029aee76da996bd28c70

Contents?: true

Size: 1.71 KB

Versions: 23

Compression:

Stored size: 1.71 KB

Contents

#
# Author:: Tim Hinderliter (<tim@opscode.com>)
# Copyright:: Copyright (c) 2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Set of methods to create model objects for spec tests.
# None of these methods save or otherwise commit the objects they
# create; they simply initialize the respective model object and
# set its name (and other important attributes, where appropriate).

def make_node(name)
  res = Chef::Node.new
  res.name(name)
  res
end

def make_role(name)
  res = Chef::Role.new
  res.name(name)
  res
end

def make_environment(name)
  res = Chef::Environment.new
  res.name(name)
  res
end

def make_cookbook(name, version)
  res = Chef::CookbookVersion.new(name)
  res.version = version
  res
end

def make_runlist(*items)
  res = Chef::RunList.new
  items.each do |item|
    res << item
  end
  res
end

# Take an Array of cookbook_versions,
# And return a hash like:
# {
#   "cookbook_name" => [CookbookVersion, CookbookVersion],
# }
def make_filtered_cookbook_hash(*array_cookbook_versions)
  array_cookbook_versions.inject({}) do |res, cookbook_version|
    res[cookbook_version.name] ||= Array.new
    res[cookbook_version.name] << cookbook_version
    res
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
chef-server-api-0.10.4 spec/spec_model_helper.rb
chef-server-api-0.10.4.rc.6 spec/spec_model_helper.rb
chef-server-api-0.10.4.rc.5 spec/spec_model_helper.rb
chef-server-api-0.10.4.rc.4 spec/spec_model_helper.rb
chef-server-api-0.10.4.rc.3 spec/spec_model_helper.rb
chef-server-api-0.10.4.rc.2 spec/spec_model_helper.rb
chef-server-api-0.10.4.rc.1 spec/spec_model_helper.rb
chef-server-api-0.10.2 spec/spec_model_helper.rb
chef-server-api-0.10.0 spec/spec_model_helper.rb
chef-server-api-0.10.0.rc.2 spec/spec_model_helper.rb
chef-server-api-0.10.0.rc.1 spec/spec_model_helper.rb
chef-server-api-0.10.0.rc.0 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.10 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.9 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.8 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.7 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.6 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.5 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.4 spec/spec_model_helper.rb
chef-server-api-0.10.0.beta.3 spec/spec_model_helper.rb