forked from integrity/integrity
/
installer_test.rb
79 lines (59 loc) · 2.28 KB
/
installer_test.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
require File.dirname(__FILE__) + "/../helpers/acceptance"
require "integrity/installer"
class InstallerTest < Test::Unit::AcceptanceTestCase
include FileUtils
story <<-EOS
As an user,
I want to easily install Integrity
So that I can spend time actually writing code
EOS
before(:each) do
rm_rf root if File.directory?(root)
end
def root
Pathname("/tmp/i-haz-integrity")
end
def install(option="")
installer = File.dirname(__FILE__) + "/../../bin/integrity"
IO.popen("#{installer} install #{root} #{option}".strip).read
end
scenario "Installing integrity into a given directory" do
post_install_message = install
assert post_install_message.include?("Awesome")
assert post_install_message.include?("integrity migrate_db #{root.join("config.yml")}")
assert root.join("builds").directory?
assert root.join("log").directory?
assert ! root.join("public").directory?
assert ! root.join("tmp").directory?
assert ! root.join("Rakefile").file?
assert ! root.join("integrity.rb").file?
assert ! root.join(".gems").file?
assert ! root.join("thin.yml").file?
assert root.join("config.ru").file?
config = YAML.load_file(root.join("config.yml"))
config[:export_directory].should == root.join("builds").to_s
config[:database_uri].should == "sqlite3://#{root}/integrity.db"
config[:log].should == root.join("log/integrity.log").to_s
end
scenario "Installing integrity for Passenger" do
install("--passenger")
assert root.join("public").directory?
assert root.join("tmp").directory?
end
scenario "Installing Integrity for Thin" do
install("--thin")
config = YAML.load_file(root.join("thin.yml"))
config["chdir"].should == root.to_s
config["pid"].should == root.join("thin.pid").to_s
config["rackup"].should == root.join("config.ru").to_s
config["log"].should == root.join("log/thin.log").to_s
end
scenario "Installing Integrity for Heroku" do
message = install("--heroku")
assert_equal "integrity --version 0.1.9.0", root.join(".gems").read.chomp
assert root.join("Rakefile").file?
assert root.join("integrity-config.rb").file?
assert root.join("config.ru").file?
assert message.include?("ready to be deployed onto Heroku")
end
end