-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage_scenarios_spec.rb
77 lines (65 loc) · 2.51 KB
/
usage_scenarios_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
require_relative '../helpers'
include Helpers
describe "usage scenarios" do
PLAYGROUND = "#{BASE_DIR}/playground"
APP_COOKBOOK_DIR = "#{PLAYGROUND}/sample-toplevel-cookbook"
INFRA_REPO_DIR = "#{PLAYGROUND}/sample-infrastructure-repo"
BASEBOX = "opscode_ubuntu-12.04_provisionerless"
before(:all) do
require 'fileutils'
FileUtils.rm_rf LOGFILE
FileUtils.rm_rf PLAYGROUND
FileUtils.mkdir PLAYGROUND
end
describe "checking prerequisites" do
it "has Git installed" do
run_cmd("git --version").should match('git version')
end
it "has Vagrant 1.6, 1.7 or 1.8 installed" do
run_cmd("vagrant -v").should match(/(1.6|1.7|1.8)/)
end
it "has 'vagrant-omnibus' plugin installed" do
vagrant_plugin_installed "vagrant-omnibus"
end
it "has 'vagrant-berkshelf' plugin installed" do
vagrant_plugin_installed "vagrant-berkshelf"
end
it "has 'vagrant-toplevel-cookbooks' plugin installed" do
vagrant_plugin_installed "vagrant-toplevel-cookbooks"
end
end
describe "developing top-level cookbooks" do
it "clones an top-level cookbook via `git clone`" do
cmd_succeeds("cd #{PLAYGROUND} && git clone https://github.com/tknerr/sample-toplevel-cookbook.git")
end
it "installs gem dependencies via `bundle install`" do
cmd_succeeds("cd #{APP_COOKBOOK_DIR} && bundle install")
end
it "runs the unit tests via `rake test`" do
cmd_succeeds("cd #{APP_COOKBOOK_DIR} && rake test")
end
it "runs the integration tests via `rake integration`" do
cmd_succeeds("cd #{APP_COOKBOOK_DIR} && rake integration")
end
end
describe "managing infrastructure" do
it "clones an infrastructure repo via `git clone`" do
cmd_succeeds("cd #{PLAYGROUND} && git clone https://github.com/tknerr/sample-infrastructure-repo.git")
end
it "brings up a VM via `vagrant up`" do
cmd_succeeds("cd #{INFRA_REPO_DIR} && vagrant up app_v1")
end
it "can talk to that VM via `vagrant ssh`" do
run_cmd("cd #{INFRA_REPO_DIR} && vagrant ssh app_v1 -c 'pwd'").should match("/home/vagrant")
end
it "can access the sample.html page served by the VM" do
http_get("http://localhost:8080/sample.html").should match("Chuck Norris")
end
it "can provision that VM via `vagrant provision`" do
cmd_succeeds("cd #{INFRA_REPO_DIR} && vagrant provision app_v1")
end
it "can destroy that VM via `vagrant destroy`" do
cmd_succeeds("cd #{INFRA_REPO_DIR} && vagrant destroy -f app_v1")
end
end
end