在过去的几周里,我一直在编写 ChefSpec 单元测试套件,并设法用它做了很多事情,但我发现了一个让我难过的场景。我有一个包含“aws”食谱的默认食谱的食谱,它依次安装right_aws
然后继续require
它。
但是 ChefSpec 运行程序似乎有问题,吐出 Ruby LoadError:
LoadError
---------
cannot load such file -- right_aws
Cookbook Trace:
---------------
/var/folders/0r/cg1hmpkj2nb3wh6slrg1hkhm0000gn/T/d20140612-36208-q1ecjj/cookbooks/aws/recipes/default.rb:25:in `from_file'
/var/folders/0r/cg1hmpkj2nb3wh6slrg1hkhm0000gn/T/d20140612-36208-q1ecjj/cookbooks/acmecorp-postgresql/recipes/server.rb:71:in `from_file'
Relevant File Content:
----------------------
/var/folders/0r/cg1hmpkj2nb3wh6slrg1hkhm0000gn/T/d20140612-36208-q1ecjj/cookbooks/aws/recipes/default.rb:
18: #
19:
20: chef_gem "right_aws" do
21: version node['aws']['right_aws_version']
22: action :install
23: end
24:
25>> require 'right_aws'
26:
有没有办法require 'right_aws'
在我的测试中模拟“aws”食谱中的那条线?推荐吗?在运行 ChefSpec 测试的系统上简单地安装 right_aws gem 会更好吗?