vito 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/README.md +32 -19
- data/Rakefile +5 -20
- data/bin/vito +1 -1
- data/lib/vito.rb +5 -1
- data/lib/vito/command_line/command.rb +21 -0
- data/lib/vito/command_line/document_flags.rb +30 -0
- data/lib/vito/command_line/options.rb +41 -0
- data/lib/vito/command_line/string.rb +35 -0
- data/lib/vito/commands/help.rb +62 -0
- data/lib/vito/commands/install.rb +17 -0
- data/lib/vito/core_ext/string.rb +33 -0
- data/lib/vito/dsl/installation.rb +5 -2
- data/lib/vito/dsl/server.rb +3 -3
- data/lib/vito/dsl_file.rb +11 -5
- data/lib/vito/operating_systems/ubuntu_10.rb +4 -0
- data/lib/vito/output.rb +3 -1
- data/lib/vito/recipe.rb +29 -4
- data/lib/vito/recipes/apache/install.rb +155 -0
- data/lib/vito/recipes/apache/service.rb +20 -0
- data/lib/vito/recipes/git/install.rb +39 -0
- data/lib/vito/recipes/passenger/install.rb +83 -0
- data/lib/vito/recipes/passenger/paths.rb +27 -0
- data/lib/vito/recipes/postgres/install.rb +106 -0
- data/lib/vito/recipes/rbenv/install.rb +54 -0
- data/lib/vito/recipes/ruby/install.rb +57 -0
- data/lib/vito/recipes/ruby/paths.rb +19 -0
- data/lib/vito/tasks/vagrant_bootstrap.rb +49 -0
- data/lib/vito/tests/vagrant_test_box.rb +44 -0
- data/lib/vito/utils/program_version.rb +2 -2
- data/lib/vito/version.rb +1 -1
- data/spec/acceptance/recipes/apache_acceptance_spec.rb +25 -0
- data/spec/acceptance/recipes/git_acceptance_spec.rb +11 -11
- data/spec/acceptance/recipes/postgres_acceptance_spec.rb +11 -11
- data/spec/acceptance/recipes/rbenv_acceptance_spec.rb +13 -13
- data/spec/acceptance/recipes/ruby_acceptance_spec.rb +15 -15
- data/spec/support/vagrant.rb +21 -16
- data/spec/vagrant_boxes/centos63/.gitkeep +0 -0
- data/{Vagrantfile → spec/vagrant_boxes/centos63/Vagrantfile} +5 -4
- data/spec/vagrant_boxes/ubuntu10/Vagrantfile +100 -0
- data/spec/vagrant_boxes/ubuntu12/Vagrantfile +100 -0
- data/spec/vito/command_line/command_spec.rb +20 -0
- data/spec/vito/command_line/options_spec.rb +50 -0
- data/spec/vito/command_line/string_spec.rb +32 -0
- data/spec/vito/commands/install_spec.rb +9 -0
- data/spec/vito/connection_spec.rb +2 -2
- data/spec/vito/core_ext/string_spec.rb +19 -0
- data/spec/vito/dsl/installation_spec.rb +2 -2
- data/spec/vito/dsl_file_spec.rb +56 -18
- data/spec/vito/output_spec.rb +2 -2
- data/spec/vito/recipe_spec.rb +53 -3
- data/spec/vito/recipes/apache/install_spec.rb +140 -0
- data/spec/vito/recipes/passenger/paths_spec.rb +18 -0
- data/spec/vito/recipes/ruby_spec.rb +5 -5
- data/spec/vito/tasks/vagrant_bootstrap_spec.rb +65 -0
- data/spec/vito/tests/vagrant_test_box_spec.rb +69 -0
- data/spec/vito/utils/program_version_spec.rb +4 -2
- data/templates/apache2/vito_site +12 -0
- data/vito.gemspec +1 -1
- data/vito.rb +7 -5
- metadata +53 -13
- data/lib/vito/recipes/git.rb +0 -37
- data/lib/vito/recipes/postgres.rb +0 -104
- data/lib/vito/recipes/rbenv.rb +0 -47
- data/lib/vito/recipes/ruby.rb +0 -43
- data/lib/vito/shell_initializer.rb +0 -21
- data/spec/vito/shell_initializer_spec.rb +0 -22
@@ -12,7 +12,7 @@ describe Vito::Connection do
|
|
12
12
|
let(:command) { "echo" }
|
13
13
|
|
14
14
|
its(:success?) { should == true }
|
15
|
-
its(:result) { should == "Alex
|
15
|
+
its(:result) { should == "Alex" }
|
16
16
|
end
|
17
17
|
|
18
18
|
context "invalid command" do
|
@@ -20,7 +20,7 @@ describe Vito::Connection do
|
|
20
20
|
|
21
21
|
it "raises error and logs its messages" do
|
22
22
|
Vito::Log.should_receive(:raise).with("An error occurred. Here's the stacktrace:")
|
23
|
-
Vito::Log.should_receive(:raise).with(
|
23
|
+
Vito::Log.should_receive(:raise).with(/sh.*harrr.*not found\n/)
|
24
24
|
Vito::Log.stub(:raise)
|
25
25
|
|
26
26
|
expect{ subject }.to raise_error "Error."
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "vito/core_ext/string"
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
describe "#camelize" do
|
5
|
+
specify "ruby_on_rails returns RubyOnRails" do
|
6
|
+
"ruby_on_rails".camelize.should == "RubyOnRails"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#constantize" do
|
11
|
+
specify "'String'.constantize returns String" do
|
12
|
+
"String".constantize.should == String
|
13
|
+
end
|
14
|
+
|
15
|
+
specify "'Heya'.constantize raises NameError" do
|
16
|
+
expect { "Heya".constantize }.to raise_error NameError, "uninitialized constant Heya"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -9,8 +9,8 @@ describe Vito::Dsl::Installation do
|
|
9
9
|
|
10
10
|
describe "#install" do
|
11
11
|
it "installs each recipes" do
|
12
|
-
ruby.should_receive(:
|
13
|
-
Vito::Recipes::Ruby.stub(:new).with(options, connection) { ruby }
|
12
|
+
ruby.should_receive(:install)
|
13
|
+
Vito::Recipes::Ruby::Install.stub(:new).with(options, connection) { ruby }
|
14
14
|
subject.install
|
15
15
|
end
|
16
16
|
end
|
data/spec/vito/dsl_file_spec.rb
CHANGED
@@ -1,35 +1,73 @@
|
|
1
|
-
require "
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Vito::DslFile do
|
4
4
|
let(:server) { double }
|
5
|
+
let(:passed_in_file) { nil }
|
6
|
+
let(:command_line) { double(options: double(file: passed_in_file)) }
|
5
7
|
|
6
|
-
subject { described_class.new }
|
7
|
-
|
8
|
-
before do
|
9
|
-
stub_const("Vito::Dsl::Server", Class.new)
|
10
|
-
end
|
8
|
+
subject { described_class.new(command_line) }
|
11
9
|
|
12
10
|
describe "#run" do
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
describe "basic block operation" do
|
12
|
+
before do
|
13
|
+
stub_const("Vito::Dsl::Server", Class.new)
|
14
|
+
Vito::Dsl::Server.stub(:new).with([:hey]) { server }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "runs the server block evaluating it as string" do
|
18
|
+
server.should_receive(:instance_eval)
|
19
|
+
|
20
|
+
subject.run <<-str
|
21
|
+
server :hey do
|
22
|
+
|
23
|
+
end
|
24
|
+
str
|
25
|
+
end
|
16
26
|
|
17
|
-
|
18
|
-
|
27
|
+
it "runs the server as a Ruby block" do
|
28
|
+
server.should_receive(:instance_eval)
|
19
29
|
|
20
|
-
|
21
|
-
|
30
|
+
subject.run do
|
31
|
+
server :hey do
|
22
32
|
|
33
|
+
end
|
23
34
|
end
|
24
|
-
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "advanced block operation" do
|
39
|
+
it "calls commands inside the block and passes subblocks to the recipe" do
|
40
|
+
Vito::Recipes::Apache::Install.any_instance.should_receive(:with).with(:passenger)
|
41
|
+
Vito::Recipes::Apache::Install.any_instance.should_receive(:vhosts).with(path: "/var/projects")
|
42
|
+
Vito::Recipes::Apache::Install.any_instance.should_receive(:install)
|
43
|
+
subject.run do
|
44
|
+
server(:hey) do
|
45
|
+
connection :ssh, command: "whatever"
|
46
|
+
install :apache do
|
47
|
+
with :passenger
|
48
|
+
vhosts path: "/var/projects"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
25
53
|
end
|
26
54
|
|
27
|
-
|
28
|
-
|
55
|
+
describe "reading the vito file" do
|
56
|
+
context "default vito.rb file" do
|
57
|
+
let(:passed_in_file) { nil }
|
58
|
+
|
59
|
+
it "uses vito.rb file" do
|
60
|
+
File.should_receive(:open).with("vito.rb") { double(read: "") }
|
61
|
+
subject.run
|
62
|
+
end
|
63
|
+
end
|
29
64
|
|
30
|
-
|
31
|
-
|
65
|
+
context "custom DSL file" do
|
66
|
+
let(:passed_in_file) { "some_file.rb" }
|
32
67
|
|
68
|
+
it "uses some_file.rb file" do
|
69
|
+
File.should_receive(:open).with("some_file.rb") { double(read: "") }
|
70
|
+
subject.run
|
33
71
|
end
|
34
72
|
end
|
35
73
|
end
|
data/spec/vito/output_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "vito/output"
|
2
2
|
|
3
3
|
describe Vito::ConnectionOutput do
|
4
|
-
let(:stdout) { double(read:
|
4
|
+
let(:stdout) { double(read: "stdout_string\n\n\s") }
|
5
5
|
let(:stderr) { double(read: :stderr_string) }
|
6
6
|
let(:thread) { double(value: double(exitstatus: 0)) }
|
7
7
|
|
@@ -21,7 +21,7 @@ describe Vito::ConnectionOutput do
|
|
21
21
|
describe "result" do
|
22
22
|
it "returns stdout string in case of a successful command" do
|
23
23
|
subject.stub(:success?) { true }
|
24
|
-
subject.result.should ==
|
24
|
+
subject.result.should == "stdout_string"
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns stdout string in case of a successful command" do
|
data/spec/vito/recipe_spec.rb
CHANGED
@@ -10,9 +10,59 @@ describe DummyRecipe do
|
|
10
10
|
|
11
11
|
subject { described_class.new(options, connection) }
|
12
12
|
|
13
|
-
describe "#
|
13
|
+
describe "#with" do
|
14
|
+
context "with a package specified" do
|
15
|
+
before do
|
16
|
+
subject.with(:passenger, version: "2.1")
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "dynamic methods generated" do
|
20
|
+
it "generates a dynamic method with the same name of the package" do
|
21
|
+
subject.passenger.should == { version: "2.1" }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with no package specified" do
|
27
|
+
it "raises error on package name that wasn't specified" do
|
28
|
+
expect { subject.passenger }.to raise_error
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#with?" do
|
34
|
+
context "with a package specified" do
|
35
|
+
before { subject.with(:passenger, version: "2.1") }
|
36
|
+
|
37
|
+
it "returns true for that package" do
|
38
|
+
subject.with?(:passenger).should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns false for other packages" do
|
42
|
+
subject.with?(:packagex).should be_false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns false when no package is specified" do
|
47
|
+
subject.with?(:packagex).should be_false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#install" do
|
52
|
+
it "raises an error if undefined" do
|
53
|
+
expect { subject.install }.to raise_error "DummyRecipe recipe needs to define a #install method"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#remove" do
|
58
|
+
it "raises an error if undefined" do
|
59
|
+
expect { subject.remove }.to raise_error "DummyRecipe recipe needs to define a #remove method"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#update" do
|
14
64
|
it "raises an error if undefined" do
|
15
|
-
expect { subject.
|
65
|
+
expect { subject.update }.to raise_error "DummyRecipe recipe needs to define a #update method"
|
16
66
|
end
|
17
67
|
end
|
18
68
|
|
@@ -29,7 +79,7 @@ describe DummyRecipe do
|
|
29
79
|
operating_system.should_receive(:install_dependencies).with(dependencies)
|
30
80
|
Vito::OperatingSystem.stub(:new).with(connection) { double(os: operating_system) }
|
31
81
|
|
32
|
-
subject.install_os_dependencies
|
82
|
+
subject.install_os_dependencies(dependencies)
|
33
83
|
end
|
34
84
|
end
|
35
85
|
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Vito::Recipes::Apache::Install do
|
4
|
+
let(:options) { {} }
|
5
|
+
let(:connection) { double }
|
6
|
+
let(:os) { double.as_null_object }
|
7
|
+
|
8
|
+
subject { described_class.new(options, connection) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
subject.stub(:query) { double.as_null_object }
|
12
|
+
subject.stub(:system)
|
13
|
+
subject.stub(:run_command)
|
14
|
+
subject.stub(:depends_on_recipe)
|
15
|
+
#STDOUT.stub(:puts)
|
16
|
+
Vito::Log.stub(:write)
|
17
|
+
|
18
|
+
Vito::OperatingSystem.stub_chain(:new, :os) { os }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#install" do
|
22
|
+
context "no vhosts or dependency package (with) defined" do
|
23
|
+
after do
|
24
|
+
subject.install
|
25
|
+
end
|
26
|
+
|
27
|
+
it "installs os dependencies" do
|
28
|
+
subject.should_receive(:install_os_dependencies)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "install apache2-mpm-prefork" do
|
32
|
+
subject.should_receive(:run_command).with(/sudo.*apt-get.*apache2-mpm-prefork/i)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "doesn't install passenger" do
|
36
|
+
subject.should_not_receive(:depends_on_recipe)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "shouldn't disable 000-default site" do
|
40
|
+
subject.should_not_receive(:run_command).with("sudo a2dissite 000-default")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "doesn't set up vhosts" do
|
44
|
+
Vito::Log.should_not_receive(:write).with(/setting.*hosts/i)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "restarts the Apache2 service" do
|
48
|
+
os.should_receive(:service).with(:apache2, :restart)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "vhosts and with(:passenger) defined" do
|
53
|
+
before do
|
54
|
+
subject.with :passenger
|
55
|
+
subject.vhosts with: :ssl, path: "/var/projects"
|
56
|
+
subject.stub(:site_already_enabled?) { false }
|
57
|
+
end
|
58
|
+
|
59
|
+
it "installs os dependencies" do
|
60
|
+
subject.should_receive(:install_os_dependencies)
|
61
|
+
subject.install
|
62
|
+
end
|
63
|
+
|
64
|
+
it "install apache2-mpm-prefork" do
|
65
|
+
subject.should_receive(:run_command).with(/sudo.*apt-get.*apache2-mpm-prefork/i)
|
66
|
+
subject.install
|
67
|
+
end
|
68
|
+
|
69
|
+
it "installs passenger" do
|
70
|
+
subject.should_receive(:depends_on_recipe).with(:passenger, {server: :apache})
|
71
|
+
subject.install
|
72
|
+
end
|
73
|
+
|
74
|
+
it "disables 000-default site" do
|
75
|
+
subject.should_receive(:run_command).with("sudo a2dissite 000-default")
|
76
|
+
subject.install
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "setting up vhosts" do
|
80
|
+
it "starts setting up vhosts" do
|
81
|
+
Vito::Log.should_receive(:write).with(/setting.*hosts/i)
|
82
|
+
subject.install
|
83
|
+
end
|
84
|
+
|
85
|
+
it "downloads the correct file" do
|
86
|
+
subject.should_receive(:run_command).with(/curl.*github.*templates.*vito_rails_site/i)
|
87
|
+
subject.install
|
88
|
+
end
|
89
|
+
|
90
|
+
it "replaces VITO_PORT" do
|
91
|
+
subject.should_receive(:run_command).with(/sed.*VITO_PORT/i)
|
92
|
+
subject.install
|
93
|
+
end
|
94
|
+
|
95
|
+
it "replaces VITO_SERVERNAME" do
|
96
|
+
subject.should_receive(:run_command).with(/sed.*VITO_SERVERNAME/i)
|
97
|
+
subject.install
|
98
|
+
end
|
99
|
+
|
100
|
+
context "Rails app" do
|
101
|
+
it "replaces VITO_RAILS_PUBLIC_PATH" do
|
102
|
+
subject.should_receive(:run_command).with(/sed.*VITO_RAILS_PUBLIC_PATH/i)
|
103
|
+
subject.install
|
104
|
+
end
|
105
|
+
|
106
|
+
it "replaces VITO_RAILS_ENV" do
|
107
|
+
subject.should_receive(:run_command).with(/sed.*VITO_RAILS_ENV/i)
|
108
|
+
subject.install
|
109
|
+
end
|
110
|
+
|
111
|
+
it "replaces VITO_SITE_PATH" do
|
112
|
+
subject.should_receive(:run_command)
|
113
|
+
.with(/sed.*VITO_SITE_PATH.*var.*projects/i)
|
114
|
+
subject.install
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it "defines the user for the project dir" do
|
120
|
+
subject.should_receive(:run_command).with(/\[ -d \/var\/projects.*|| sudo mkdir -p/i)
|
121
|
+
subject.install
|
122
|
+
end
|
123
|
+
|
124
|
+
it "defines the user for the project dir" do
|
125
|
+
subject.should_receive(:run_command).with(/sudo chown \\\$USER:admin/i)
|
126
|
+
subject.install
|
127
|
+
end
|
128
|
+
|
129
|
+
it "activates port 80 vhosts" do
|
130
|
+
subject.should_receive(:run_command).with(/sudo a2ensite vito_rails_site_80/i)
|
131
|
+
subject.install
|
132
|
+
end
|
133
|
+
|
134
|
+
it "restarts the Apache2 service" do
|
135
|
+
os.should_receive(:service).with(:apache2, :restart)
|
136
|
+
subject.install
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Vito::Recipes::Passenger::Paths do
|
4
|
+
let(:recipe) { double }
|
5
|
+
let(:result) { double(result: gemspec_path) }
|
6
|
+
let(:gemspec_path) { "/Users/kurko/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/passenger-4.0.10/passenger.gemspec\n" }
|
7
|
+
|
8
|
+
subject { described_class.new(recipe) }
|
9
|
+
|
10
|
+
describe "#mod_passenger" do
|
11
|
+
context "apache" do
|
12
|
+
it "returns the mod_passenger path" do
|
13
|
+
recipe.stub(:query).with("gem contents passenger|grep gemspec") { result }
|
14
|
+
subject.mod_passenger(:apache).should == "/Users/kurko/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/passenger-4.0.10/buildout/apache2/mod_passenger.so"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -4,21 +4,21 @@ describe Vito::Recipes::Ruby do
|
|
4
4
|
let(:options) { double("options").as_null_object }
|
5
5
|
let(:connection) { double("connection").as_null_object }
|
6
6
|
|
7
|
-
subject { Vito::Recipes::Ruby.new(options, connection) }
|
7
|
+
subject { Vito::Recipes::Ruby::Install.new(options, connection) }
|
8
8
|
|
9
9
|
before do
|
10
10
|
STDOUT.stub(:puts)
|
11
11
|
Vito::ConnectionOutput.stub(:write)
|
12
12
|
end
|
13
13
|
|
14
|
-
describe "#
|
14
|
+
describe "#install" do
|
15
15
|
it "installs rbenv" do
|
16
16
|
subject.stub(:install_os_dependencies)
|
17
17
|
|
18
18
|
rbenv = double
|
19
|
-
rbenv.should_receive(:
|
20
|
-
Vito::Recipes::Rbenv.stub(:new).with(anything, connection) { rbenv }
|
21
|
-
subject.
|
19
|
+
rbenv.should_receive(:install)
|
20
|
+
Vito::Recipes::Rbenv::Install.stub(:new).with(anything, connection) { rbenv }
|
21
|
+
subject.install
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "vito/tasks/vagrant_bootstrap"
|
2
|
+
|
3
|
+
describe Vito::Tasks::VagrantBootstrap do
|
4
|
+
subject { described_class.new("ubuntu12") }
|
5
|
+
|
6
|
+
before do
|
7
|
+
subject.stub(:system)
|
8
|
+
subject.stub(:`)
|
9
|
+
STDOUT.stub(:puts)
|
10
|
+
Dir.stub(:chdir)
|
11
|
+
subject.stub(:snapshot_exist?) { true }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#install" do
|
15
|
+
it "outputs a message about the setup about to start" do
|
16
|
+
STDOUT.should_receive(:puts).with(/ubuntu12.*ubuntu12_test_box.*vagrant_boxes\/ubuntu12/)
|
17
|
+
subject.install
|
18
|
+
end
|
19
|
+
|
20
|
+
it "changes dir to the box one" do
|
21
|
+
Dir.stub(:chdir)
|
22
|
+
Dir.should_receive(:chdir).with("spec/vagrant_boxes/ubuntu12")
|
23
|
+
subject.install
|
24
|
+
end
|
25
|
+
|
26
|
+
it "starts the vagrant box and halts it" do
|
27
|
+
subject.should_receive(:system).with("vagrant up && vagrant halt")
|
28
|
+
subject.install
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "snapshot plugin installation" do
|
32
|
+
it "installs the snapshot plugin if it's not present" do
|
33
|
+
subject.stub(:system) { false }
|
34
|
+
subject.should_receive(:system).with("vagrant plugin install vagrant-vbox-snapshot")
|
35
|
+
subject.install
|
36
|
+
end
|
37
|
+
|
38
|
+
it " doesn't install the snapshot plugin if it's present" do
|
39
|
+
subject.stub(:system) { true }
|
40
|
+
subject.should_not_receive(:system).with("vagrant plugin install vagrant-vbox-snapshot")
|
41
|
+
subject.install
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "snapshot creation" do
|
46
|
+
it "takes a initial snapshot if none exist" do
|
47
|
+
subject.stub(:snapshot_exist?) { false }
|
48
|
+
subject.should_receive(:system).with("vagrant snapshot take ubuntu12_initial_box")
|
49
|
+
subject.install
|
50
|
+
end
|
51
|
+
|
52
|
+
it "doesn't take a initial snapshot if it already exists" do
|
53
|
+
subject.stub(:snapshot_exist?) { true }
|
54
|
+
subject.should_not_receive(:system).with("vagrant snapshot take ubuntu12_initial_box")
|
55
|
+
subject.install
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "gets back to the original dir" do
|
60
|
+
Dir.stub(:pwd) { :original_path }
|
61
|
+
Dir.should_receive(:chdir).with(:original_path)
|
62
|
+
subject.install
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|