summaryrefslogtreecommitdiff
path: root/chef/spec/spec_helper.rb
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-04-04 17:34:21 -0400
committerHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-04-24 12:47:17 -0400
commitfaacb3b7d05040d5bd36159928bcee7a35020477 (patch)
tree61c3807ae994ccc7d0fdc28fb9473e996f74386c /chef/spec/spec_helper.rb
parent1172bb6b4459d0cf0a0dc8d44ac8454a58aa4ede (diff)
downloadchef-faacb3b7d05040d5bd36159928bcee7a35020477.tar.gz
[CHEF-3020][RSPEC] Reduced spec_helpers to essentials
If you need to add something shared globally, add it into a file in spec/support. Since everything except for spec/support/platform gets automatically loaded, there is no need to clutter up spec_helpers
Diffstat (limited to 'chef/spec/spec_helper.rb')
-rw-r--r--chef/spec/spec_helper.rb50
1 files changed, 6 insertions, 44 deletions
diff --git a/chef/spec/spec_helper.rb b/chef/spec/spec_helper.rb
index f09c782bd7..bdef3eade0 100644
--- a/chef/spec/spec_helper.rb
+++ b/chef/spec/spec_helper.rb
@@ -14,7 +14,9 @@
# 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.
-#
+
+# If you need to add anything in here, don't.
+# Add it to one of the files in spec/support
# Abuse ruby's constant lookup to avoid undefined constant errors
module Shef
@@ -41,6 +43,9 @@ require 'chef/util/file_edit'
Dir[File.join(File.dirname(__FILE__), 'lib', '**', '*.rb')].sort.each { |lib| require lib }
+# Explicitly require spec helpers that need to load first
+require 'spec/support/platform_helpers'
+
# Autoloads support files
# Excludes support/platforms by default
# Do not change the gsub.
@@ -49,49 +54,6 @@ Dir["spec/support/**/*.rb"].
map { |f| f.gsub(%r{.rb$}, '') }.
each { |f| require f }
-CHEF_SPEC_DATA = File.expand_path(File.dirname(__FILE__) + "/data/")
-CHEF_SPEC_BACKUP_PATH = File.join(Dir.tmpdir, 'test-backup-path')
-
-Chef::Config[:log_level] = :fatal
-Chef::Config[:cache_type] = "Memory"
-Chef::Config[:cache_options] = { }
-Chef::Config[:persistent_queue] = false
-Chef::Config[:file_backup_path] = CHEF_SPEC_BACKUP_PATH
-
-Chef::Log.level(Chef::Config.log_level)
-Chef::Config.solo(false)
-
-Chef::Log.logger = Logger.new(StringIO.new)
-
-def windows?
- if RUBY_PLATFORM =~ /mswin|mingw|windows/
- true
- else
- false
- end
-end
-
-DEV_NULL = windows? ? 'NUL' : '/dev/null'
-
-def redefine_argv(value)
- Object.send(:remove_const, :ARGV)
- Object.send(:const_set, :ARGV, value)
-end
-
-def with_argv(*argv)
- original_argv = ARGV
- redefine_argv(argv.flatten)
- begin
- yield
- ensure
- redefine_argv(original_argv)
- end
-end
-
-def sha256_checksum(path)
- Digest::SHA256.hexdigest(File.read(path))
-end
-
RSpec.configure do |config|
config.include(Matchers)
end