summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/checksum/storage/filesystem_spec.rb70
-rw-r--r--spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb4
-rw-r--r--spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb4
-rw-r--r--spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb4
-rw-r--r--spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb4
-rw-r--r--spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb4
-rw-r--r--spec/unit/knife/node_environment_set_spec.rb (renamed from spec/unit/knife/node_environment_spec.rb)6
-rw-r--r--spec/unit/resource/remote_file_spec.rb29
-rw-r--r--spec/unit/resource_spec.rb2
9 files changed, 43 insertions, 84 deletions
diff --git a/spec/unit/checksum/storage/filesystem_spec.rb b/spec/unit/checksum/storage/filesystem_spec.rb
deleted file mode 100644
index 755a64fe07..0000000000
--- a/spec/unit/checksum/storage/filesystem_spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2010 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'spec_helper'
-require 'chef/checksum/storage/filesystem'
-
-describe Chef::Checksum::Storage::Filesystem do
-
- before do
- Chef::Log.logger = Logger.new(StringIO.new)
-
- @now = Time.now
-
- Time.stub(:now).and_return(@now)
- Chef::Config.stub(:checksum_path).and_return("/var/chef/checksums")
-
- @checksum_of_the_file = "3fafecfb15585ede6b840158cbc2f399"
- @storage = Chef::Checksum::Storage::Filesystem.new("/not/used/path", @checksum_of_the_file)
- end
-
- it "has the path to the file in the checksum repo" do
- @storage.file_location.should == "/var/chef/checksums/3f/3fafecfb15585ede6b840158cbc2f399"
- end
-
- it "has the path the file's subdirectory in the checksum repo" do
- @storage.checksum_repo_directory.should == "/var/chef/checksums/3f"
- end
-
- it "commits a file from a given location to the checksum repo location" do
- File.should_receive(:rename).with("/tmp/arbitrary_file_location", @storage.file_location)
- FileUtils.should_receive(:mkdir_p).with("/var/chef/checksums/3f")
-
- @storage.commit("/tmp/arbitrary_file_location")
- end
-
- it "reverts committing a file" do
- File.should_receive(:rename).with("/tmp/arbitrary_file_location", @storage.file_location)
- FileUtils.should_receive(:mkdir_p).with("/var/chef/checksums/3f")
- @storage.commit("/tmp/arbitrary_file_location")
-
- File.should_receive(:rename).with(@storage.file_location, "/tmp/arbitrary_file_location")
- @storage.revert("/tmp/arbitrary_file_location")
- end
-
- it "deletes the file" do
- FileUtils.should_receive(:rm).with(@storage.file_location)
- @storage.purge
- end
-
- it "successfully purges even if its file has been deleted from the repo" do
- FileUtils.should_receive(:rm).with(@storage.file_location).and_raise(Errno::ENOENT)
- lambda {@storage.purge}.should_not raise_error
- end
-
-end
diff --git a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
index bea7eeed21..95911689e4 100644
--- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
@@ -42,8 +42,8 @@ describe Chef::Formatters::ErrorInspectors::CompileErrorInspector do
@description = Chef::Formatters::ErrorDescription.new("Error Evaluating File:")
@exception = NoMethodError.new("undefined method `this_is_not_a_valid_method' for Chef::Resource::File")
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
+ @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
end
describe "when scrubbing backtraces" do
diff --git a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
index c573dc016b..06d45472e4 100644
--- a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
@@ -25,8 +25,8 @@ describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
@description = Chef::Formatters::ErrorDescription.new("Error Resolving Cookbooks for Run List:")
@outputter_output = StringIO.new
- @outputter = Chef::Formatters::Outputter.new(@outputter_output, STDERR)
- # @outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
+ @outputter = Chef::Formatters::IndentableOutputStream.new(@outputter_output, STDERR)
+ # @outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
end
describe "when explaining a 403 error" do
diff --git a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
index e586f5e3b3..87c3708ef1 100644
--- a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
@@ -21,8 +21,8 @@ require 'spec_helper'
describe Chef::Formatters::ErrorInspectors::CookbookSyncErrorInspector do
before do
@description = Chef::Formatters::ErrorDescription.new("Error Expanding RunList:")
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
+ @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
end
describe "when explaining a 502 error" do
diff --git a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
index 8cafbcc9d6..6691553ddd 100644
--- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -39,8 +39,8 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
before do
@description = Chef::Formatters::ErrorDescription.new("Error Converging Resource:")
@stdout = StringIO.new
- @outputter = Chef::Formatters::Outputter.new(@stdout, STDERR)
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
+ @outputter = Chef::Formatters::IndentableOutputStream.new(@stdout, STDERR)
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
Chef::Config.stub(:cookbook_path).and_return([ "/var/chef/cache" ])
end
diff --git a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
index 56a6eceec3..7f68c4fba4 100644
--- a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
@@ -26,8 +26,8 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
end
@description = Chef::Formatters::ErrorDescription.new("Error Expanding RunList:")
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
- #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
+ @outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
+ #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
end
describe "when explaining a missing role error" do
diff --git a/spec/unit/knife/node_environment_spec.rb b/spec/unit/knife/node_environment_set_spec.rb
index dc7599e6cb..46ee1fea18 100644
--- a/spec/unit/knife/node_environment_spec.rb
+++ b/spec/unit/knife/node_environment_set_spec.rb
@@ -18,10 +18,10 @@
require 'spec_helper'
-describe Chef::Knife::NodeEnvironment do
+describe Chef::Knife::NodeEnvironmentSet do
before(:each) do
Chef::Config[:node_name] = "webmonkey.example.com"
- @knife = Chef::Knife::NodeEnvironment.new
+ @knife = Chef::Knife::NodeEnvironmentSet.new
@knife.name_args = [ "adam", "bar" ]
@knife.stub(:output).and_return(true)
@node = Chef::Node.new()
@@ -72,7 +72,7 @@ describe Chef::Knife::NodeEnvironment do
begin ; @knife.run ; rescue SystemExit ; end
- @stdout.string.should eq "USAGE: knife node environment NODE ENVIRONMENT\n"
+ @stdout.string.should eq "USAGE: knife node environment set NODE ENVIRONMENT\n"
@stderr.string.should eq "FATAL: You must specify a node name and an environment.\n"
end
end
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index 643bc8ba21..8f1633119d 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -50,20 +50,49 @@ describe Chef::Resource::RemoteFile do
@resource.source.should eql([ "http://opscode.com/" ])
end
+ it "should accept a delayed evalutator (string) for the remote file source" do
+ @resource.source Chef::DelayedEvaluator.new {"http://opscode.com/"}
+ @resource.source.should eql([ "http://opscode.com/" ])
+ end
+
it "should accept an array of URIs for the remote file source" do
@resource.source([ "http://opscode.com/", "http://puppetlabs.com/" ])
@resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
end
+ it "should accept a delated evaluator (array) for the remote file source" do
+ @resource.source Chef::DelayedEvaluator.new { [ "http://opscode.com/", "http://puppetlabs.com/" ] }
+ @resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
+ end
+
it "should accept an multiple URIs as arguments for the remote file source" do
@resource.source("http://opscode.com/", "http://puppetlabs.com/")
@resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
end
+ it "should only accept a single argument if a delayed evalutor is used" do
+ lambda {
+ @resource.source("http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"})
+ }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ end
+
+ it "should only accept a single array item if a delayed evalutor is used" do
+ lambda {
+ @resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"}])
+ }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ end
+
it "does not accept a non-URI as the source" do
lambda { @resource.source("not-a-uri") }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
+ it "does not accept a non-URI as the source when read from a delayed evaluator" do
+ lambda {
+ @resource.source(Chef::DelayedEvaluator.new {"not-a-uri"})
+ @resource.source
+ }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ end
+
it "should raise an exception when source is an empty array" do
lambda { @resource.source([]) }.should raise_error(ArgumentError)
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 60f3bdb8ea..82ffdeba98 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -612,7 +612,7 @@ describe Chef::Resource do
it "should print \"skipped due to action :nothing\" message for doc formatter when action is :nothing" do
fdoc = Chef::Formatters.new(:doc, STDOUT, STDERR)
@run_context.stub(:events).and_return(fdoc)
- fdoc.should_receive(:puts).with(" (skipped due to action :nothing)")
+ fdoc.should_receive(:puts).with(" (skipped due to action :nothing)", anything())
@resource.should_skip?(:nothing)
end