ors 0.2.10 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +71 -0
- data/bin/ors +1 -1
- data/lib/ors.rb +21 -2
- data/lib/ors/base.rb +30 -0
- data/lib/ors/commands/base.rb +56 -12
- data/lib/ors/commands/changes.rb +21 -7
- data/lib/ors/commands/console.rb +16 -18
- data/lib/ors/commands/deploy.rb +24 -13
- data/lib/ors/commands/env.rb +9 -9
- data/lib/ors/commands/exec.rb +14 -7
- data/lib/ors/commands/help.rb +9 -11
- data/lib/ors/commands/logs.rb +16 -14
- data/lib/ors/commands/migrate.rb +8 -9
- data/lib/ors/commands/restart.rb +9 -11
- data/lib/ors/commands/ruby.rb +8 -6
- data/lib/ors/commands/runner.rb +29 -25
- data/lib/ors/commands/setup.rb +16 -16
- data/lib/ors/commands/start.rb +9 -11
- data/lib/ors/commands/stop.rb +9 -11
- data/lib/ors/commands/symlink.rb +31 -0
- data/lib/ors/commands/timestamps.rb +27 -0
- data/lib/ors/commands/update.rb +15 -11
- data/lib/ors/config.rb +88 -58
- data/lib/ors/helpers.rb +107 -76
- data/lib/ors/log_unifier.rb +2 -2
- data/lib/ors/version.rb +2 -2
- data/spec/ors/{command_spec.rb → base_spec.rb} +11 -8
- data/spec/ors/commands/base_spec.rb +17 -9
- data/spec/ors/commands/deploy_spec.rb +4 -3
- data/spec/ors/commands/runner_spec.rb +8 -27
- data/spec/ors/commands/timestamps_spec.rb +16 -0
- data/spec/ors/commands/update_spec.rb +8 -3
- data/spec/ors/config_spec.rb +56 -61
- data/spec/ors/helpers_spec.rb +6 -2
- data/spec/ors/log_unifier_spec.rb +2 -2
- metadata +82 -57
- data/README +0 -52
- data/lib/ors/command.rb +0 -46
- data/lib/ors/commands/check.rb +0 -27
- data/lib/ors/commands/sync.rb +0 -27
- data/lib/ors/core_ext.rb +0 -53
- data/spec/ors/commands/check_spec.rb +0 -15
data/lib/ors/helpers.rb
CHANGED
@@ -1,90 +1,131 @@
|
|
1
|
-
|
1
|
+
class ORS
|
2
2
|
module Helpers
|
3
3
|
|
4
|
-
|
4
|
+
# Helpers for Commands when parsing in ARGV
|
5
|
+
module ParseHelpers
|
6
|
+
def parse_remote_and_or_branch
|
7
|
+
option = ORS.config[:args].shift
|
5
8
|
|
6
|
-
|
7
|
-
|
9
|
+
unless option.nil?
|
10
|
+
if option.match(/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+$/)
|
11
|
+
remote, *branch = option.split("/")
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
ORS.config[:remote] = remote
|
14
|
+
ORS.config[:branch] = branch.join('/')
|
15
|
+
else
|
16
|
+
ORS.config[:remote] = option
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
14
20
|
end
|
21
|
+
include ParseHelpers
|
15
22
|
|
16
|
-
def setup_ruby server
|
17
|
-
info "[#{server}] installing ruby and gems..."
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
24
|
+
# Helpers for preparing to run a command on a server
|
25
|
+
module PrepareHelpers
|
26
|
+
def prepare_environment
|
27
|
+
[%({ cd #{ORS.config[:deploy_directory]} > /dev/null; })]
|
28
|
+
end
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
def prepare_environment_with_rvm
|
31
|
+
[%(source ~/.rvm/scripts/rvm)] + prepare_environment
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
def prepare_initial_environment
|
35
|
+
# We do a source and a git checkout here because the master
|
36
|
+
# branch may not always contain the proper rvmrc/Gemfile
|
37
|
+
# we need when setting up the rest of the deploy
|
38
|
+
prepare_environment_with_rvm + [
|
39
|
+
%(git checkout -q -f #{ORS.config[:remote]}/#{ORS.config[:branch]}),
|
40
|
+
%(git reset --hard),
|
41
|
+
%(source .rvmrc)
|
42
|
+
]
|
43
|
+
end
|
34
44
|
end
|
45
|
+
include PrepareHelpers
|
46
|
+
|
47
|
+
# Helpers for commands for re-use
|
48
|
+
module CommandHelpers
|
49
|
+
def setup_repo server
|
50
|
+
info "[#{server}] installing codebase..."
|
51
|
+
|
52
|
+
execute_command server, %(cd #{ORS.config[:base_path]}),
|
53
|
+
%(rm -rf #{ORS.config[:deploy_directory]}),
|
54
|
+
%(git clone #{ORS.config[:remote_url]} #{ORS.config[:deploy_directory]}),
|
55
|
+
%(mkdir -p #{ORS.config[:deploy_directory]}/tmp/pids),
|
56
|
+
%(mkdir -p #{ORS.config[:deploy_directory]}/log)
|
57
|
+
end
|
35
58
|
|
36
|
-
|
37
|
-
|
59
|
+
def setup_ruby server
|
60
|
+
info "[#{server}] installing ruby and gems..."
|
38
61
|
|
39
|
-
|
40
|
-
|
41
|
-
|
62
|
+
execute_command server, prepare_initial_environment,
|
63
|
+
%(gem install rubygems-update),
|
64
|
+
%(gem update --system),
|
65
|
+
%(gem install bundler),
|
66
|
+
%(bundle install --without development test osx_development > bundler.log)
|
67
|
+
end
|
42
68
|
|
43
|
-
|
44
|
-
|
69
|
+
def update_code server
|
70
|
+
info "[#{server}] updating codebase..."
|
45
71
|
|
46
|
-
|
47
|
-
|
48
|
-
|
72
|
+
execute_command server, prepare_environment,
|
73
|
+
%(git fetch #{ORS.config[:remote]}),
|
74
|
+
%(git checkout -q -f #{ORS.config[:remote]}/#{ORS.config[:branch]}),
|
75
|
+
%(git reset --hard),
|
76
|
+
%(git submodule update --init)
|
77
|
+
end
|
49
78
|
|
50
|
-
|
51
|
-
|
79
|
+
def bundle_install server
|
80
|
+
info "[#{server}] installing bundle..."
|
52
81
|
|
53
|
-
|
54
|
-
|
55
|
-
|
82
|
+
execute_command server, prepare_environment_with_rvm,
|
83
|
+
%(bundle install --without development test osx_development > bundler.log)
|
84
|
+
end
|
56
85
|
|
57
|
-
|
58
|
-
|
86
|
+
def start_server server
|
87
|
+
info "[#{server}] starting unicorn..."
|
59
88
|
|
60
|
-
|
61
|
-
|
62
|
-
|
89
|
+
execute_command server, prepare_environment_with_rvm,
|
90
|
+
%(if [ -f config.ru ]; then RAILS_ENV=#{ORS.config[:environment]} bundle exec unicorn -c config/unicorn.rb -D; else RAILS_ENV=#{ORS.config[:environment]} bundle exec unicorn_rails -c config/unicorn.rb -D; fi)
|
91
|
+
end
|
63
92
|
|
64
|
-
|
65
|
-
|
93
|
+
def stop_server server
|
94
|
+
info "[#{server}] stopping unicorn..."
|
66
95
|
|
67
|
-
|
68
|
-
|
69
|
-
|
96
|
+
execute_command server, prepare_environment,
|
97
|
+
%(kill \\`cat tmp/pids/unicorn.pid\\`)
|
98
|
+
end
|
70
99
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
100
|
+
def restart_server server
|
101
|
+
info "[#{server}] restarting unicorn..."
|
102
|
+
|
103
|
+
execute_command server, prepare_environment,
|
104
|
+
%(kill -USR2 \\`cat tmp/pids/unicorn.pid\\`)
|
105
|
+
end
|
106
|
+
|
107
|
+
def run_migrations server
|
108
|
+
info "[#{server}] running migrations..."
|
109
|
+
|
110
|
+
execute_command server, prepare_environment_with_rvm,
|
111
|
+
%(RAILS_ENV=#{ORS.config[:environment]} bundle exec rake db:migrate db:seed)
|
112
|
+
end
|
77
113
|
end
|
114
|
+
include CommandHelpers
|
115
|
+
|
116
|
+
#
|
117
|
+
# How we actually execute/build commands
|
118
|
+
#
|
78
119
|
|
79
120
|
# options = {:exec => ?, :capture => ?, :quiet_ssh => ?}
|
80
|
-
def execute_command
|
121
|
+
def execute_command(server, *command_array)
|
81
122
|
options = {:exec => false, :capture => false, :quiet_ssh => false}
|
82
123
|
options.merge!(command_array.pop) if command_array.last.is_a?(Hash)
|
83
124
|
options[:local] = true if server.to_s == "localhost"
|
84
125
|
|
85
126
|
command = build_command(server, command_array, options)
|
86
127
|
|
87
|
-
if pretending
|
128
|
+
if ORS.config[:pretending]
|
88
129
|
info("[#{server}] #{command}")
|
89
130
|
else
|
90
131
|
if options[:exec]
|
@@ -120,29 +161,20 @@ module ORS
|
|
120
161
|
if options[:local]
|
121
162
|
commands
|
122
163
|
else
|
123
|
-
if use_gateway
|
124
|
-
%(ssh #{quiet_ssh}#{psuedo_tty}#{gateway} 'ssh #{quiet_ssh}#{psuedo_tty}#{
|
164
|
+
if ORS.config[:use_gateway]
|
165
|
+
%(ssh #{quiet_ssh}#{psuedo_tty}#{ORS.config[:gateway]} 'ssh #{quiet_ssh}#{psuedo_tty}#{ORS.config[:user]}@#{server} "#{commands}"')
|
125
166
|
else
|
126
|
-
%(ssh #{quiet_ssh}#{psuedo_tty}#{
|
167
|
+
%(ssh #{quiet_ssh}#{psuedo_tty}#{ORS.config[:user]}@#{server} "#{commands}")
|
127
168
|
end
|
128
169
|
end
|
129
170
|
end
|
130
171
|
|
131
|
-
def
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
%(git reset --hard),
|
138
|
-
%(cd ../),
|
139
|
-
%(cd #{deploy_directory})
|
140
|
-
]
|
141
|
-
end
|
142
|
-
|
143
|
-
def prepare_environment
|
144
|
-
[%(source ~/.rvm/scripts/rvm),
|
145
|
-
%({ cd #{deploy_directory} > /dev/null; })] # Silence RVM's "Using... gemset..."
|
172
|
+
def execute_in_parallel servers
|
173
|
+
servers.map do |server|
|
174
|
+
Thread.new(server) do |server|
|
175
|
+
yield server
|
176
|
+
end
|
177
|
+
end.map {|thread| thread.join }
|
146
178
|
end
|
147
179
|
|
148
180
|
def info message
|
@@ -153,6 +185,5 @@ module ORS
|
|
153
185
|
info message
|
154
186
|
exit 1
|
155
187
|
end
|
156
|
-
|
157
188
|
end
|
158
189
|
end
|
data/lib/ors/log_unifier.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
class ORS
|
2
2
|
|
3
3
|
class LogUnifier
|
4
4
|
|
@@ -20,7 +20,7 @@ module ORS
|
|
20
20
|
sort_by {|entry| entry[:timestamp] }.
|
21
21
|
map do |entry|
|
22
22
|
entry[:lines].
|
23
|
-
map {|line| ["[#{entry[:server]}]".ljust(pretty_adjust + 3), line].join }.
|
23
|
+
map {|line| ["[#{entry[:server]}]".ljust(pretty_adjust + 3), line].join.strip }.
|
24
24
|
join "\n"
|
25
25
|
end.
|
26
26
|
flatten.
|
data/lib/ors/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.
|
1
|
+
class ORS
|
2
|
+
VERSION = "0.3.0"
|
3
3
|
end
|
@@ -1,31 +1,34 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe ORS
|
3
|
+
describe ORS do
|
4
4
|
|
5
|
-
subject { ORS
|
5
|
+
subject { ORS.new }
|
6
6
|
|
7
7
|
context ".run" do
|
8
|
+
before do
|
9
|
+
@command = ORS::Commands::Help.new
|
10
|
+
mock(ORS::Commands::Help).new { @command }
|
11
|
+
mock(@command).setup { "setup" }
|
12
|
+
mock(@command).execute { "execute" }
|
13
|
+
end
|
8
14
|
|
9
15
|
it "should execute help when the command is help" do
|
10
|
-
mock(ORS::Commands::Help).new { mock!.execute.subject }
|
11
16
|
subject.run ["help"]
|
12
17
|
end
|
13
18
|
|
14
19
|
it "should execute help when no command is given" do
|
15
|
-
mock(ORS::Commands::Help).new { mock!.execute.subject }
|
16
20
|
subject.run []
|
17
21
|
end
|
18
22
|
|
19
23
|
it "should execute help when an unknown command is given" do
|
20
|
-
mock(ORS::Commands::Help).new { mock!.execute.subject }
|
21
24
|
subject.run ["as0d9fja0s9djf"]
|
22
25
|
end
|
26
|
+
end
|
23
27
|
|
28
|
+
context ".run with version" do
|
24
29
|
it "should show the version when given version as a command" do
|
25
|
-
mock(
|
30
|
+
mock($stdout).puts("ORS v#{ORS::VERSION}")
|
26
31
|
subject.run ["version"]
|
27
32
|
end
|
28
|
-
|
29
33
|
end
|
30
|
-
|
31
34
|
end
|
@@ -2,20 +2,28 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe ORS::Commands::Base do
|
4
4
|
|
5
|
+
before do
|
6
|
+
@command = ORS::Commands::Base.new
|
7
|
+
mock(ORS::Commands::Base).new { @command }
|
8
|
+
end
|
9
|
+
|
5
10
|
context ".run" do
|
11
|
+
it "should instantiate the command and call #setup and #execute on it" do
|
12
|
+
mock(ORS.config).finalize! {true}
|
13
|
+
mock(ORS.config).valid? {true}
|
14
|
+
mock(@command).setup.subject
|
15
|
+
mock(@command).execute.subject
|
6
16
|
|
7
|
-
|
8
|
-
klass = mock!.new { mock!.execute.subject }.subject
|
9
|
-
ORS::Commands::Base.run klass
|
17
|
+
ORS::Commands::Base.run
|
10
18
|
end
|
11
|
-
|
12
19
|
end
|
13
20
|
|
14
|
-
context "
|
15
|
-
it "should
|
16
|
-
|
17
|
-
subject
|
21
|
+
context ".run_without_setup" do
|
22
|
+
it "should not run #setup but run #execute" do
|
23
|
+
dont_allow(@command).setup.subject
|
24
|
+
mock(@command).execute.subject
|
25
|
+
|
26
|
+
ORS::Commands::Base.run_without_setup
|
18
27
|
end
|
19
28
|
end
|
20
|
-
|
21
29
|
end
|
@@ -7,9 +7,10 @@ describe ORS::Commands::Deploy do
|
|
7
7
|
it "should call update, migrate, then restart" do
|
8
8
|
mock(subject).info /deploying/
|
9
9
|
|
10
|
-
mock(
|
11
|
-
mock(
|
12
|
-
mock(
|
10
|
+
mock(ORS::Commands::Update).run_without_setup
|
11
|
+
mock(ORS::Commands::Symlink).run_without_setup
|
12
|
+
mock(ORS::Commands::Migrate).run_without_setup
|
13
|
+
mock(ORS::Commands::Restart).run_without_setup
|
13
14
|
|
14
15
|
subject.execute
|
15
16
|
end
|
@@ -4,39 +4,20 @@ describe ORS::Commands::Runner do
|
|
4
4
|
|
5
5
|
context "#run" do
|
6
6
|
before do
|
7
|
-
|
8
|
-
|
7
|
+
ORS.config[:name] = 'abc/growhealthy'
|
8
|
+
ORS.config[:environment] = 'production'
|
9
9
|
end
|
10
10
|
|
11
|
-
it "should require
|
12
|
-
lambda {subject.execute}.should raise_error
|
11
|
+
it "should require 'ruby code'" do
|
12
|
+
lambda {subject.setup; subject.execute}.should raise_error
|
13
13
|
end
|
14
14
|
|
15
|
-
it "should
|
16
|
-
ORS
|
17
|
-
lambda {subject.execute}.should raise_error
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should require an argument to -c" do
|
21
|
-
ORS::Config.parse_options %w(--c)
|
22
|
-
lambda {subject.execute}.should raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should require a non-empty argument to --code" do
|
26
|
-
ORS::Config.parse_options ['--code', ' ']
|
27
|
-
lambda {subject.execute}.should raise_error
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be successful with an argument to --code" do
|
31
|
-
ORS::Config.parse_options %w(--code true)
|
15
|
+
it "should be successful with some 'ruby code'" do
|
16
|
+
ORS.config.parse_options ["ruby code"]
|
32
17
|
mock(subject).execute_command(is_a(String), is_a(Array), is_a(String), is_a(Hash)).returns("results")
|
33
|
-
lambda {subject.execute}.should_not raise_error
|
34
|
-
end
|
35
18
|
|
36
|
-
|
37
|
-
|
38
|
-
mock(subject).execute_command(is_a(String), is_a(Array), is_a(String), is_a(Hash)).returns("results")
|
39
|
-
lambda {subject.execute}.should_not raise_error
|
19
|
+
|
20
|
+
lambda {subject.setup; subject.execute}.should_not raise_error
|
40
21
|
end
|
41
22
|
end
|
42
23
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ORS::Commands::Timestamps do
|
4
|
+
|
5
|
+
context "#execute" do
|
6
|
+
it "should get restart.timestamp from all of the app servers" do
|
7
|
+
ORS.config[:pretending] = false
|
8
|
+
ORS.config[:app_servers] = mock!.map { ["server", "timestamp"] }.subject
|
9
|
+
|
10
|
+
mock($stdout).puts("server\ntimestamp")
|
11
|
+
|
12
|
+
subject.execute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -3,10 +3,15 @@ require "spec_helper"
|
|
3
3
|
describe ORS::Commands::Update do
|
4
4
|
|
5
5
|
context "#run" do
|
6
|
+
before do
|
7
|
+
ORS.config.parse_options([])
|
8
|
+
ORS.config.parse_config_file
|
9
|
+
end
|
10
|
+
|
6
11
|
it "should update code, bundle install, and set up cron" do
|
7
|
-
|
8
|
-
|
9
|
-
|
12
|
+
ORS.config[:all_servers] = :all_servers
|
13
|
+
ORS.config[:ruby_servers] = :ruby_servers
|
14
|
+
ORS.config[:cron_server] = :cron_server
|
10
15
|
|
11
16
|
mock(subject).info /updating/
|
12
17
|
mock(subject).execute_in_parallel(:all_servers)
|
data/spec/ors/config_spec.rb
CHANGED
@@ -2,98 +2,66 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe ORS::Config do
|
4
4
|
|
5
|
-
subject {
|
5
|
+
subject { ORS::Config.new([]) }
|
6
6
|
|
7
7
|
context ".parse_options" do
|
8
|
-
it("should default pretend to false") { subject
|
9
|
-
it("should default use_gateway to true") { subject
|
10
|
-
it("should default rails2 to false") { subject.rails2.should be_false }
|
8
|
+
it("should default pretend to false") { subject[:pretending].should be_false }
|
9
|
+
it("should default use_gateway to true") { subject[:use_gateway].should be_true }
|
11
10
|
|
12
11
|
it "should set the environment when it is given" do
|
13
|
-
|
14
|
-
subject
|
12
|
+
subject.parse_options %w(to foobar -p)
|
13
|
+
subject[:environment].should == "foobar"
|
15
14
|
end
|
16
15
|
|
17
16
|
it "should set pretend to true if -p is given" do
|
18
|
-
|
19
|
-
|
17
|
+
subject[:pretending] = false
|
18
|
+
subject.parse_options %w(-p)
|
20
19
|
|
21
|
-
subject
|
20
|
+
subject[:pretending].should be_true
|
22
21
|
end
|
23
22
|
|
24
23
|
it "should set pretend to true if --pretend is given" do
|
25
|
-
|
26
|
-
|
24
|
+
subject[:pretending] = false
|
25
|
+
subject.parse_options %w(--pretend)
|
27
26
|
|
28
|
-
subject
|
27
|
+
subject[:pretending].should be_true
|
29
28
|
end
|
30
29
|
|
31
30
|
it "should set use_gateway to false if -ng is given" do
|
32
|
-
|
33
|
-
|
31
|
+
subject[:use_gateway] = true
|
32
|
+
subject.parse_options %w(-ng)
|
34
33
|
|
35
|
-
subject
|
34
|
+
subject[:use_gateway].should be_false
|
36
35
|
end
|
37
36
|
|
38
37
|
it "should set use_gateway to false if --no-gateway is given" do
|
39
|
-
|
40
|
-
|
38
|
+
subject[:use_gateway] = true
|
39
|
+
subject.parse_options %w(--no-gateway)
|
41
40
|
|
42
|
-
subject
|
41
|
+
subject[:use_gateway].should be_false
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
context ".
|
45
|
+
context ".valid?" do
|
47
46
|
|
48
|
-
it "should be true when there is a name
|
49
|
-
subject.name
|
50
|
-
subject.environment = "production"
|
47
|
+
it "should be true when there is a name" do
|
48
|
+
mock(subject).name { "foo" }
|
51
49
|
|
52
|
-
|
50
|
+
subject.valid?.should be_true
|
53
51
|
end
|
54
52
|
|
55
|
-
it "should be false when there is a name
|
56
|
-
subject.name
|
57
|
-
subject.environment = "-p"
|
53
|
+
it "should be false when there is a blank name" do
|
54
|
+
mock(subject).name { "" }
|
58
55
|
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should be false when there is a valid environment but a blank name" do
|
63
|
-
subject.name = ""
|
64
|
-
subject.environment = "production"
|
65
|
-
|
66
|
-
ORS::Config.valid_options?.should be_false
|
56
|
+
subject.valid?.should be_false
|
67
57
|
end
|
68
58
|
|
69
59
|
end
|
70
60
|
|
71
61
|
context "#all_servers" do
|
72
62
|
it "should return all servers" do
|
73
|
-
subject.
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
context "config permanence" do
|
78
|
-
before do
|
79
|
-
class ORS::OtherConfig; include ORS::Config; end
|
80
|
-
@other_config = ORS::OtherConfig.new
|
81
|
-
|
82
|
-
class ORS::ConfigTest; include ORS::Config; end
|
83
|
-
@some_config = ORS::ConfigTest.new
|
84
|
-
end
|
85
|
-
|
86
|
-
%w(use_gateway pretending).each do |accessor|
|
87
|
-
it "should allow you to set #{accessor}" do
|
88
|
-
ORS::Config.should respond_to("#{accessor}")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should know if its #{accessor} across classes" do
|
92
|
-
ORS::Config.send("#{accessor}=", true)
|
93
|
-
|
94
|
-
@some_config.send(accessor).should == true
|
95
|
-
@other_config.send(accessor).should == true
|
96
|
-
end
|
63
|
+
subject.finalize!
|
64
|
+
subject[:all_servers].should == (subject[:web_servers] + subject[:app_servers] + [subject[:migration_server]])
|
97
65
|
end
|
98
66
|
end
|
99
67
|
|
@@ -105,13 +73,40 @@ describe ORS::Config do
|
|
105
73
|
"git@github.com:testing/github" => "testing/github",
|
106
74
|
"git@ghub.com:testing/gitlabhq.git" => "testing/gitlabhq",
|
107
75
|
"git@ghub.com:gitlabhq.git" => "gitlabhq",
|
108
|
-
"git://ghub.com/gitlabhq.git" => "gitlabhq"
|
76
|
+
"git://ghub.com/gitlabhq.git" => "gitlabhq",
|
77
|
+
"git://ghub.com/level_git.git" => "level_git",
|
78
|
+
"git://ghub.com/level-up/two.git" => "level-up/two"
|
109
79
|
}.each do |remote, name|
|
110
80
|
it "should handle a remote origin url such as #{remote}" do
|
111
|
-
|
112
|
-
|
81
|
+
stub(subject).git { mock!.config { {"remote.origin.url" => remote} }}
|
82
|
+
subject.send(:name).should == name
|
113
83
|
end
|
114
84
|
end
|
115
85
|
end
|
116
86
|
|
87
|
+
context "#remote_from_git" do
|
88
|
+
before do
|
89
|
+
subject[:remote] = "origin"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should raise an error if the remote doesn't exist" do
|
93
|
+
stub(subject).git { mock!.config { {"remote.oregon.url" => "git://github.com/testing/git.git"} }}
|
94
|
+
|
95
|
+
lambda { subject.send(:remote_url) }.should raise_error
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should return the remote based on the remote alias (origin)" do
|
99
|
+
stub(subject).git { mock!.config { {"remote.origin.url" => "git://github.com/testing/git.git"} }}
|
100
|
+
|
101
|
+
subject.send(:remote_url).should == "git://github.com/testing/git.git"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return the remote based on the remote alias (arbit)" do
|
105
|
+
subject[:remote] = "arbit"
|
106
|
+
stub(subject).git { mock!.config { {"remote.arbit.url" => "git://github.com/arbit/git.git"} }}
|
107
|
+
|
108
|
+
subject.send(:remote_url).should == "git://github.com/arbit/git.git"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
117
112
|
end
|