summaryrefslogtreecommitdiff
path: root/spec/unit/application/base_spec.rb
blob: ce9046460365a1845f6b465c058091862b344053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require "spec_helper"

describe Chef::Application::Base, "setup_application" do
  let(:validation_path) { "" }

  context "when validation key is supplied" do
    before do
      @app = Chef::Application::Base.new
      tempfile = Tempfile.new(validation_path)
      tempfile.write "string"
      tempfile.close
      @path = tempfile.path
      Chef::Config.validation_key = @path
    end

    context "when key is in current directory" do
      it "should find with full path of validation_key" do
        validation_path = "validation.pem"
        expect(Chef::Config.validation_key).to eql(@path)
      end
    end

    context "when path is given" do
      validation_path = "/tmp/validation.pem"
      it "should find validation_key" do
        expect(Chef::Config.validation_key).to eql(@path)
      end
    end
  end

  context "when validation key is not supplied" do
    it "should return default path for validation_key" do
      if windows?
        expect(Chef::Config.validation_key).to eql("C:\\chef\\validation.pem")
      else
        expect(Chef::Config.validation_key).to eql("/etc/chef/validation.pem")
      end
    end
  end
end