草庐IT

chefspec

全部标签

ruby - 关于 Ruby/ChefSpec 编码风格的反馈

我是Ruby的新手,但过去两周我一直在对Chef测试进行大量研究。该测试使用ChefSpec和Fauxhai,但它看起来不是很“像ruby”,我希望社区能给我一些编码风格的建议。有没有更好的方法来编写这样的嵌套循环?Recipe/foo/recipes/default.rbpackage"foo"doaction:installendRecipe/foo/spec/default_spec.rbrequire'chefspec'describe'foo::default'doplatforms={"debian"=>['6.0.5'],"ubuntu"=>['12.04','10.04

ruby - chefspec:设置要在配方中的所有测试中使用的全局节点属性

我目前正在编写一个chefspec配方,它设置某些节点属性,这是完成我的单元测试所必需的。我目前在每次测试中都设置这些属性,这看起来很浪费。我希望以不重复代码的方式执行此操作,即“全局属性?”。我目前的工作配方如下:#encoding:UTF-8require_relative'../spec_helper'osd_device='/ceph-1-osd'describe'ceph::per-host-osd'dolet(:runner){ChefSpec::Runner.new}let(:chef_run){runner.converge(described_recipe)}let(

ruby - 使用 ChefSpec 基于模板测试文件初始化

我的Recipe中有以下模板文件创建:template"my_file"dopath"my_path"source"my_file.erb"owner"root"group"root"mode"0644"variables(@template_variables)notifies:restart,resources(service:"my_service")end以及我的ChefSpec测试中的以下断言:chef_run.shouldcreate_file"my_file"chef_run.file("my_file").shouldbe_owned_by('root','root')

ruby - ChefSpec 不应测试包含的 Recipe

我已经为安装JenkinsCI制作了一本说明书。它使用yumRecipe中的key和repository资源,所以我最终得到以下配方:yum_key"RPM-GPG-KEY-jenkins"dourl"http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key"action:addendyum_repository"jenkins"dodescription"Jenkins-CI3rdpartyrepository"url"http://pkg.jenkins-ci.org/redhat"key"RPM-GPG-KEY-jenkins"act

ruby - Chefspec 重复加载库并发出警告 "already initialized constant CONSTANT"

我有一本带图书馆的ChefRecipe,例如库.rb。它包含一个CONSTANT:CONSTANT='constant'当我为这本Recipe编写单元测试时,它总是给我警告:(Someprefix...)warning:alreadyinitializedconstantCONSTANT(Someprefix...)warning:previousdefinitionofCONSTANTwashere警告反复出现,次数为示例(测试用例)减一。我认为这是因为chefspec为每个示例加载一次库。谁能告诉我如何让库只加载一次,或者如何禁用警告消息? 最佳答案