/
automatic_spec.rb
99 lines (75 loc) · 2.27 KB
/
automatic_spec.rb
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
# Name:: Automatic::Ruby
# Author:: kzgs
# 774 <http://id774.net>
# Created:: Mar 9, 2012
# Updated:: Jan 24, 2015
# Copyright:: Copyright (c) 2012-2015 Automatic Ruby Developers.
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
require 'automatic'
describe Automatic do
describe "#run" do
describe "with a root dir which has default recipe" do
subject {
Automatic.run(:recipe => "",
:root_dir => APP_ROOT,
:user_dir => APP_ROOT + "/spec/user_dir")
}
it { expect { subject }.to raise_error }
end
end
describe "#version" do
subject { Automatic.const_get(:VERSION) }
it { expect(subject).to eq "14.12.2-devel" }
end
describe "#(root)_dir" do
subject { Automatic.root_dir }
it { expect(subject).to eq APP_ROOT }
end
describe "#(config)_dir" do
subject { Automatic.config_dir }
it { expect(subject).to eq APP_ROOT+"/config" }
end
describe "#user_dir= in test env" do
before(:all) do
Automatic.user_dir = File.join(APP_ROOT, "spec/user_dir")
end
describe "#user_dir" do
subject { Automatic.user_dir }
it "return valid value" do
expect(subject).to eq File.join(APP_ROOT, "spec/user_dir")
end
end
describe "#user_plugins_dir" do
subject { Automatic.user_plugins_dir }
it "return valid value" do
expect(subject).to eq File.join(APP_ROOT, "spec/user_dir/plugins")
end
end
after(:all) do
Automatic.user_dir = nil
end
end
describe "#set_user_dir in other env" do
before(:all) do
ENV["AUTOMATIC_RUBY_ENV"] = "other"
Automatic.user_dir = nil
end
describe "#user_dir" do
subject { Automatic.user_dir }
it "return valid value" do
expect(subject).to eq File.expand_path("~/") + "/.automatic"
end
end
describe "#user_plugins_dir" do
subject { Automatic.user_plugins_dir }
it "return valid value" do
expect(subject).to eq File.expand_path("~/") + "/.automatic/plugins"
end
end
after(:all) do
ENV["AUTOMATIC_RUBY_ENV"] = "test"
end
end
end