|
68 | 68 | end |
69 | 69 | end |
70 | 70 |
|
| 71 | + describe "attributes" do |
| 72 | + it "should let you set the attributes hash explicitly" do |
| 73 | + @environment.attributes({ :one => 'two' }).should == { :one => 'two' } |
| 74 | + end |
| 75 | + |
| 76 | + it "should let you return the attributes hash" do |
| 77 | + @environment.attributes({ :one => 'two' }) |
| 78 | + @environment.attributes.should == { :one => 'two' } |
| 79 | + end |
| 80 | + |
| 81 | + it "should throw an ArgumentError if we aren't a kind of hash" do |
| 82 | + lambda { @environment.attributes(Array.new) }.should raise_error(ArgumentError) |
| 83 | + end |
| 84 | + end |
| 85 | + |
71 | 86 | describe "cookbook_versions" do |
72 | 87 | before(:each) do |
73 | 88 | @cookbook_versions = { |
|
315 | 330 |
|
316 | 331 | describe "self.create_default_environment" do |
317 | 332 | it "should check if the '_default' environment exists" do |
318 | | - Chef::Environment.should_receive(:cdb_load).with('_default') |
| 333 | + @couchdb = Chef::CouchDB.new |
| 334 | + Chef::CouchDB.stub!(:new).and_return @couchdb |
| 335 | + Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new) |
319 | 336 | Chef::Environment.create_default_environment |
320 | 337 | end |
321 | 338 |
|
322 | 339 | it "should not re-create the environment if it exists" do |
323 | | - Chef::Environment.should_receive(:cdb_load).with('_default').and_return true |
| 340 | + @couchdb = Chef::CouchDB.new |
| 341 | + Chef::CouchDB.stub!(:new).and_return @couchdb |
| 342 | + Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new).and_return true |
324 | 343 | Chef::Environment.should_not_receive(:new) |
325 | 344 | Chef::Environment.create_default_environment |
326 | 345 | end |
327 | 346 |
|
328 | 347 | it "should create the environment if it doesn't exist" do |
329 | 348 | @env = Chef::Environment.new |
330 | 349 | @env.stub!(:cdb_save).and_return true |
| 350 | + @couchdb = Chef::CouchDB.new |
331 | 351 | Chef::Environment.stub!(:new).and_return @env |
| 352 | + Chef::CouchDB.stub!(:new).and_return @couchdb |
332 | 353 |
|
333 | | - Chef::Environment.should_receive(:cdb_load).with('_default').and_raise(Chef::Exceptions::CouchDBNotFound) |
| 354 | + Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new).and_raise(Chef::Exceptions::CouchDBNotFound) |
334 | 355 | Chef::Environment.should_receive(:new) |
335 | 356 | Chef::Environment.create_default_environment |
336 | 357 | end |
|
0 commit comments