|
188 | 188 | @rest.should_receive(:get_rest).with("roles/stubby") |
189 | 189 | @run_list.expand |
190 | 190 | end |
| 191 | + |
| 192 | + describe "with an environment set" do |
| 193 | + before do |
| 194 | + @role.env_run_list["production"] = Chef::RunList.new( "one", "two", "five") |
| 195 | + end |
| 196 | + |
| 197 | + it "expands the run list using the environment specific run list" do |
| 198 | + expansion = @run_list.expand("server", :environment => "production") |
| 199 | + expansion.recipes.should == %w{one two five kitty} |
| 200 | + end |
| 201 | + |
| 202 | + describe "and multiply nested roles" do |
| 203 | + before do |
| 204 | + @multiple_rest_requests = mock("Chef::REST") |
| 205 | + |
| 206 | + @role.env_run_list["production"] << "role[prod-base]" |
| 207 | + |
| 208 | + @role_prod_base = Chef::Role.new |
| 209 | + @role_prod_base.name("prod-base") |
| 210 | + @role_prod_base.env_run_list["production"] = Chef::RunList.new("role[nested-deeper]") |
| 211 | + |
| 212 | + |
| 213 | + @role_nested_deeper = Chef::Role.new |
| 214 | + @role_nested_deeper.name("nested-deeper") |
| 215 | + @role_nested_deeper.env_run_list["production"] = Chef::RunList.new("recipe[prod-secret-sauce]") |
| 216 | + end |
| 217 | + |
| 218 | + it "expands the run list using the specified environment for all nested roles" do |
| 219 | + Chef::REST.stub!(:new).and_return(@multiple_rest_requests) |
| 220 | + @multiple_rest_requests.should_receive(:get_rest).with("roles/stubby").and_return(@role) |
| 221 | + @multiple_rest_requests.should_receive(:get_rest).with("roles/prod-base").and_return(@role_prod_base) |
| 222 | + @multiple_rest_requests.should_receive(:get_rest).with("roles/nested-deeper").and_return(@role_nested_deeper) |
| 223 | + |
| 224 | + expansion = @run_list.expand("server", :environment => "production") |
| 225 | + expansion.recipes.should == %w{one two five prod-secret-sauce kitty} |
| 226 | + end |
| 227 | + |
| 228 | + end |
| 229 | + |
| 230 | + end |
| 231 | + |
191 | 232 | end |
192 | 233 |
|
193 | 234 | describe "from couchdb" do |
|
0 commit comments