I've been writing ChefSpec unit test suites for the past couple of weeks and have managed to do quite a bit with it, but I have found a scenario that got me stumped. I have a recipe that includes the 'aws' cookbook's default recipe, which in turn installs the right_aws
and then proceeds to require
it.
But the ChefSpec runner seems to have problems with it, spitting out a 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:
Is there a way to mock that require 'right_aws'
line from the 'aws' cookbook in my test? Is it recommended?
Is it better to simply install the right_aws gem on the system running ChefSpec tests?