Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Chef-3020 Fix specs on Ruby 1.8.7 #278

Closed
wants to merge 2 commits into from

2 participants

@hosh
  • Imported #make_tmpname from 1.9.2 into spec helpers
  • Marked knife exec functional test as pending when running in Ruby 1.8.7
@btm
Owner

Merged to master.

@btm btm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 25, 2012
  1. @hosh

    [CHEF-3020][RB187] Fixed specs failing on making a temporary file

    hosh authored
    Imported #make_tmpname from 1.9.2 source
  2. @hosh
This page is out of date. Refresh to see the latest.
View
4 chef/spec/functional/knife/exec_spec.rb
@@ -43,7 +43,9 @@
@server.stop
end
- it "executes a script in the context of the shef main context" do
+ pending "executes a script in the context of the shef main context", :ruby_18_only
+
+ it "executes a script in the context of the shef main context", :ruby_19_only do
@node = Chef::Node.new
@node.name("ohai-world")
response = {"rows" => [@node],"start" => 0,"total" => 1}
View
2  chef/spec/spec_helper.rb
@@ -67,6 +67,8 @@ module Shef
# Add jruby filters here
config.filter_run_excluding :windows_only => true unless windows?
config.filter_run_excluding :unix_only => true unless unix?
+ config.filter_run_excluding :ruby_18_only => true unless ruby_18?
+ config.filter_run_excluding :ruby_19_only => true unless ruby_19?
config.filter_run_excluding :requires_root => true unless ENV['USER'] == 'root'
config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root'
View
20 chef/spec/support/chef_helpers.rb
@@ -30,3 +30,23 @@
def sha256_checksum(path)
Digest::SHA256.hexdigest(File.read(path))
end
+
+# From Ruby 1.9.2+
+# Here for backwards compatibility with Ruby 1.8.7
+# http://rubydoc.info/stdlib/tmpdir/1.9.2/Dir/Tmpname
+def make_tmpname(prefix_suffix, n)
+ case prefix_suffix
+ when String
+ prefix = prefix_suffix
+ suffix = ""
+ when Array
+ prefix = prefix_suffix[0]
+ suffix = prefix_suffix[1]
+ else
+ raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
+ end
+ t = Time.now.strftime("%Y%m%d")
+ path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
+ path << "-#{n}" if n
+ path << suffix
+end
View
2  chef/spec/support/shared/functional/directory_resource.rb
@@ -76,7 +76,7 @@ def denied_acl(sid, expected_perms)
shared_context Chef::Resource::Directory do
let(:path) do
- File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname(directory_base, nil))
+ File.join(Dir.tmpdir, make_tmpname(directory_base, nil))
end
after(:each) do
View
2  chef/spec/support/shared/functional/file_resource.rb
@@ -124,7 +124,7 @@ def denied_acl(sid, expected_perms)
shared_context Chef::Resource::File do
let(:path) do
- File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname(file_base, nil))
+ File.join(Dir.tmpdir, make_tmpname(file_base, nil))
end
after(:each) do
Something went wrong with that request. Please try again.