-
Notifications
You must be signed in to change notification settings - Fork 1
/
capistrano-mountaintop_spec.rb
83 lines (63 loc) · 3.16 KB
/
capistrano-mountaintop_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
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Capistrano::Mountaintop, "loaded into capistrano" do
before do
@configuration = Capistrano::Configuration.new
@configuration.extend(Capistrano::Spec::ConfigurationExtension)
@configuration.extend(Capistrano::Mountaintop)
@campfire_room = mock('campfire room')
@configuration.set(:campfire_room, @campfire_room)
end
it "defines mountaintop:campfire:starting" do
@configuration.find_task('mountaintop:campfire:starting').should_not == nil
end
it "defines mountaintop:campfire:finished" do
@configuration.find_task('mountaintop:campfire:finished').should_not == nil
end
it "performs mountain:campfire:starting before deploy" do
@configuration.should callback('mountaintop:campfire:starting').before('deploy')
end
it "performs mountain:campfire:starting before deploy:migrations" do
@configuration.should callback('mountaintop:campfire:starting').before('deploy:migrations')
end
it "performs mountain:announce:finished after deploy" do
@configuration.should callback('mountaintop:campfire:finished').after('deploy')
end
context "in multistage environment" do
specify "mountaintop:campfire:begin speaks the user deploying, the branch being deployed, and the stage being deployed to" do
@configuration.set(:deployer, "Zim")
@configuration.set(:application, "worlddomination")
@configuration.set(:branch, "master")
@configuration.set(:stage, "staging")
@campfire_room.should_receive(:speak).with("Zim is deploying worlddomination's master to staging")
@configuration.find_and_execute_task('mountaintop:campfire:starting')
end
specify "mountaintop:campfire:finish pastes the full log" do
@configuration.set(:full_log, "I AM A LOG")
@campfire_room.should_receive(:paste).with("I AM A LOG")
@configuration.find_and_execute_task('mountaintop:campfire:finished')
end
end
context "in non-multistage environment" do
specify "mountaintop:announce:begin speaks the user deploying and the branch being deployed to production" do
@configuration.set(:deployer, "Zim")
@configuration.set(:application, "worlddomination")
@configuration.set(:branch, "master")
@campfire_room.should_receive(:speak).with("Zim is deploying worlddomination's master to production")
@configuration.find_and_execute_task('mountaintop:campfire:starting')
end
specify "mountaintop:announce:finish pastes the full log" do
@configuration.set(:full_log, "I AM A LOG")
@campfire_room.should_receive(:paste).with("I AM A LOG")
@configuration.find_and_execute_task('mountaintop:campfire:finished')
end
end
context "scm with no branch" do
specify "mountaintop:announce:begin speaks the user deploying and the branch being deployed to production" do
@configuration.set(:deployer, "Zim")
@configuration.set(:application, "worlddomination")
@configuration.set(:scm, :none)
@campfire_room.should_receive(:speak).with("Zim is deploying worlddomination to production")
@configuration.find_and_execute_task('mountaintop:campfire:starting')
end
end
end