taketo 0.1.3 → 0.2.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/Gemfile +1 -0
  2. data/Gemfile.lock +8 -0
  3. data/README.md +16 -1
  4. data/Rakefile +1 -0
  5. data/VERSION +1 -1
  6. data/bin/taketo +17 -89
  7. data/lib/taketo/actions/base_action.rb +29 -0
  8. data/lib/taketo/actions/generate_ssh_config.rb +22 -0
  9. data/lib/taketo/actions/group_action.rb +15 -0
  10. data/lib/taketo/actions/list.rb +22 -0
  11. data/lib/taketo/actions/login.rb +40 -0
  12. data/lib/taketo/actions/matches.rb +28 -0
  13. data/lib/taketo/actions/node_action.rb +15 -0
  14. data/lib/taketo/actions/server_action.rb +14 -0
  15. data/lib/taketo/actions/view.rb +24 -0
  16. data/lib/taketo/actions.rb +21 -0
  17. data/lib/taketo/associated_nodes.rb +4 -0
  18. data/lib/taketo/commands.rb +2 -1
  19. data/lib/taketo/config_validator.rb +4 -0
  20. data/lib/taketo/config_visitor.rb +3 -1
  21. data/lib/taketo/constructs/config.rb +2 -1
  22. data/lib/taketo/constructs/environment.rb +9 -0
  23. data/lib/taketo/constructs/group.rb +20 -0
  24. data/lib/taketo/constructs/project.rb +2 -1
  25. data/lib/taketo/constructs/server.rb +1 -1
  26. data/lib/taketo/constructs.rb +1 -0
  27. data/lib/taketo/constructs_factory.rb +4 -0
  28. data/lib/taketo/destination_matcher.rb +4 -4
  29. data/lib/taketo/dsl.rb +18 -17
  30. data/lib/taketo/group_list_visitor.rb +11 -0
  31. data/lib/taketo/group_resolver.rb +12 -0
  32. data/lib/taketo/{destination_resolver.rb → node_resolver.rb} +5 -27
  33. data/lib/taketo/server_resolver.rb +29 -0
  34. data/spec/acceptance/command_spec.rb +2 -1
  35. data/spec/acceptance/completion_spec.rb +26 -9
  36. data/spec/acceptance/config_dsl_spec.rb +74 -13
  37. data/spec/acceptance/config_validation_spec.rb +20 -5
  38. data/spec/acceptance/connect_to_server_spec.rb +6 -3
  39. data/spec/acceptance/error_handling_spec.rb +2 -2
  40. data/spec/acceptance/generate_ssh_config_spec.rb +1 -1
  41. data/spec/acceptance/help_spec.rb +4 -2
  42. data/spec/acceptance/location_spec.rb +2 -1
  43. data/spec/acceptance_spec_helper.rb +1 -1
  44. data/spec/lib/taketo/actions_spec.rb +17 -0
  45. data/spec/lib/taketo/associated_nodes_spec.rb +34 -0
  46. data/spec/lib/taketo/config_validator_spec.rb +1 -1
  47. data/spec/lib/taketo/constructs/config_spec.rb +4 -1
  48. data/spec/lib/taketo/constructs/environment_spec.rb +6 -1
  49. data/spec/lib/taketo/constructs/group_spec.rb +30 -0
  50. data/spec/lib/taketo/constructs/project_spec.rb +2 -0
  51. data/spec/lib/taketo/constructs/server_spec.rb +6 -2
  52. data/spec/lib/taketo/constructs_factory_spec.rb +5 -0
  53. data/spec/lib/taketo/dsl_spec.rb +86 -74
  54. data/spec/lib/taketo/group_list_visitor_spec.rb +20 -0
  55. data/spec/lib/taketo/group_resolver_spec.rb +59 -0
  56. data/spec/lib/taketo/{destination_resolver_spec.rb → server_resolver_spec.rb} +3 -29
  57. data/spec/support/helpers/construct_spec_helper.rb +9 -0
  58. data/spec/support/helpers/dsl_spec_helper.rb +31 -9
  59. data/spec/support/matchers/enclose_scope_matcher.rb +15 -7
  60. metadata +41 -20
data/lib/taketo/dsl.rb CHANGED
@@ -6,27 +6,31 @@ module Taketo
6
6
  class ConfigError < StandardError; end
7
7
 
8
8
  class << self
9
- def define_scope(scope, *args, &block)
10
- options = args.last.is_a?(Hash) ? args.pop : {}
11
- parent_scopes = args
9
+ def define_scope(scope, *parent_scopes_and_options, &scope_setup_block)
10
+ options = parent_scopes_and_options.last.is_a?(Hash) ? parent_scopes_and_options.pop : {}
11
+ parent_scopes = parent_scopes_and_options
12
12
 
13
- define_method scope do |*args, &blk|
13
+ define_method scope do |*args, &scope_block|
14
14
  ensure_nesting_allowed!(scope, parent_scopes)
15
15
  name = args.shift || options[:default_name] or raise(ArgumentError, "Name not specified")
16
16
 
17
17
  scope_object = current_scope_object.find(scope, name) { @factory.create(scope, name) }
18
18
 
19
19
  in_scope(scope, scope_object) do
20
- instance_exec(current_scope_object, &block) if block
21
- blk.call
20
+ instance_exec(current_scope_object, &scope_setup_block) if scope_setup_block
21
+ scope_block.call
22
22
  end
23
23
  end
24
+
25
+ define_method("#{scope}_scope?") do
26
+ current_scope == scope
27
+ end
24
28
  end
25
29
 
26
30
  def define_method_in_scope(name, *parent_scopes, &block)
27
- define_method name do |*args, &blk|
31
+ define_method name do |*args, &argument_block|
28
32
  ensure_nesting_allowed!(name, parent_scopes)
29
- args.push blk if blk
33
+ args.push argument_block if argument_block
30
34
  instance_exec(*args, &block)
31
35
  end
32
36
  end
@@ -56,8 +60,9 @@ module Taketo
56
60
 
57
61
  define_scope :project, :config
58
62
  define_scope :environment, :project
63
+ define_scope :group, :environment, :project, :config
59
64
 
60
- define_scope :server, :environment, :project, :config, :default_name => :default do |s|
65
+ define_scope :server, :environment, :project, :config, :group, :default_name => :default do |s|
61
66
  instance_eval(&s.default_server_config)
62
67
  end
63
68
 
@@ -75,12 +80,12 @@ module Taketo
75
80
  define_method_in_scope(:execute, :command) { |command| current_scope_object.command = command }
76
81
  define_method_in_scope(:desc, :command) { |description| current_scope_object.description = description }
77
82
 
78
- define_method_in_scope(:default_server_config, :config, :project, :environment) do |blk|
79
- current_scope_object.default_server_config = blk
83
+ define_method_in_scope(:default_server_config, :config, :project, :environment, :group) do |block|
84
+ current_scope_object.default_server_config = block
80
85
  end
81
86
 
82
- define_method_in_scope(:shared_server_config, :config) do |name, blk|
83
- @shared_server_configs.store(name.to_sym, blk)
87
+ define_method_in_scope(:shared_server_config, :config) do |name, block|
88
+ @shared_server_configs.store(name.to_sym, block)
84
89
  end
85
90
 
86
91
  define_method_in_scope(:include_shared_server_config, :server) do |*args|
@@ -101,10 +106,6 @@ module Taketo
101
106
  current_scope == scope
102
107
  end
103
108
 
104
- [:config, :project, :environment, :server, :command].each do |scope|
105
- define_method("#{scope}_scope?") { current_scope == scope }
106
- end
107
-
108
109
  def in_scope(scope, new_scope_object)
109
110
  parent_scope_object, @current_scope_object = @current_scope_object, new_scope_object
110
111
  @scope.push(scope)
@@ -0,0 +1,11 @@
1
+ require 'taketo/config_visitor'
2
+ require 'taketo/printer'
3
+
4
+ module Taketo
5
+ class GroupListVisitor < SimpleCollector(Constructs::Server)
6
+ def result
7
+ @result.map(&:path).join("\n")
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,12 @@
1
+ require 'taketo/node_resolver'
2
+
3
+ module Taketo
4
+
5
+ class GroupResolver < NodeResolver
6
+ def nodes
7
+ super.select { |n| [Taketo::Constructs::Config, Taketo::Constructs::Project, Taketo::Constructs::Environment, Taketo::Constructs::Group].include?(n.class) }
8
+ end
9
+ end
10
+
11
+ end
12
+
@@ -5,7 +5,7 @@ module Taketo
5
5
  class AmbiguousDestinationError < StandardError; end
6
6
  class NonExistentDestinationError < StandardError; end
7
7
 
8
- class DestinationResolver
8
+ class NodeResolver
9
9
  def initialize(config, path)
10
10
  @config = config
11
11
  if String(path).empty? && !String(config.default_destination).empty?
@@ -15,34 +15,11 @@ module Taketo
15
15
  @traverser = ConfigTraverser.new(@config)
16
16
  end
17
17
 
18
- def servers
19
- @servers ||= begin
20
- collector = SimpleCollector(Taketo::Constructs::Server).new
21
- @traverser.visit_depth_first(collector)
22
- collector.result
23
- end
24
- end
25
-
26
18
  def resolve
27
- resolve_by_global_alias || resolve_by_path
28
- end
29
-
30
- def resolve_by_global_alias
31
- unless @path.to_s.empty?
32
- servers.select(&:global_alias).detect { |s| s.global_alias == @path.to_s }
33
- end
19
+ resolve_by_path
34
20
  end
35
21
 
36
22
  def resolve_by_path
37
- matching_servers = servers.select { |s| s.path =~ /^#@path/ }
38
- disambiguate(matching_servers)
39
- end
40
-
41
- def get_node
42
- resolve_by_global_alias || get_node_by_path
43
- end
44
-
45
- def get_node_by_path
46
23
  matching_nodes = nodes.select { |n| n.path == @path }
47
24
  disambiguate(matching_nodes)
48
25
  end
@@ -51,14 +28,14 @@ module Taketo
51
28
  @nodes ||= begin
52
29
  collector = SimpleCollector(Taketo::Constructs::BaseConstruct).new
53
30
  @traverser.visit_depth_first(collector)
54
- collector.result
31
+ collector.result.reject { |n| Taketo::Constructs::Command === n }
55
32
  end
56
33
  end
57
34
 
58
35
  def disambiguate(results)
59
36
  case results.length
60
37
  when 0
61
- raise NonExistentDestinationError, "Can't find server for path #@path"
38
+ raise NonExistentDestinationError, "Can't find such destination: #@path"
62
39
  when 1
63
40
  results.first
64
41
  else
@@ -70,3 +47,4 @@ module Taketo
70
47
  end
71
48
  end
72
49
 
50
+
@@ -0,0 +1,29 @@
1
+ require 'taketo/node_resolver'
2
+ require 'taketo/constructs/server'
3
+
4
+ module Taketo
5
+
6
+ class ServerResolver < NodeResolver
7
+ def nodes
8
+ super.select { |n| Taketo::Constructs::Server === n }
9
+ end
10
+ alias :servers :nodes
11
+
12
+ def resolve
13
+ resolve_by_global_alias || resolve_by_path
14
+ end
15
+
16
+ def resolve_by_global_alias
17
+ unless @path.to_s.empty?
18
+ servers.select(&:global_alias).detect { |s| s.global_alias == @path.to_s }
19
+ end
20
+ end
21
+
22
+ def resolve_by_path
23
+ matching_servers = servers.select { |s| s.path =~ /^#@path/ }
24
+ disambiguate(matching_servers)
25
+ end
26
+ end
27
+
28
+ end
29
+
@@ -13,8 +13,9 @@ feature "Run explicit command on remote host" do
13
13
  CONFIG
14
14
 
15
15
  run "taketo --dry-run --command 'TERM=xterm-256color bash'"
16
- exit_status.should be_success
17
16
  stdout.should == %Q{ssh -t 1.2.3.4 "RAILS_ENV=staging TERM=xterm-256color bash"}
17
+ stderr.should be_empty
18
+ exit_status.should be_success
18
19
  end
19
20
  end
20
21
 
@@ -1,22 +1,39 @@
1
1
  require 'acceptance_spec_helper'
2
2
 
3
3
  feature "Aids completion with matches" do
4
- scenario "Show matching servers" do
5
- create_config <<-CONFIG
6
- project :foo do
4
+ background { config_exists <<-CONFIG }
5
+ project :foo do
6
+ environment :test do
7
7
  server :s1 do
8
8
  host '1.2.3.4'
9
9
  end
10
10
  end
11
+ end
11
12
 
12
- server :s10 do
13
- host '2.3.4.5'
14
- end
15
- CONFIG
13
+ server :s10 do
14
+ host '2.3.4.5'
15
+ end
16
+ CONFIG
17
+
18
+ scenario "Show servers by default" do
19
+ run "taketo --matches"
20
+ stdout.split.should =~ %w(foo:test:s1 s10)
21
+ stderr.should be_empty
22
+ exit_status.should be_success
23
+ end
24
+
25
+ scenario "Show scopes for --list" do
26
+ run "taketo --list --matches"
27
+ stdout.split.should =~ %w(foo foo:test)
28
+ stderr.should be_empty
29
+ exit_status.should be_success
30
+ end
16
31
 
17
- run "taketo s1 --matches"
32
+ scenario "Show all for --view" do
33
+ run "taketo --view --matches"
34
+ stdout.split.should =~ %w(foo foo:test foo:test:s1 s10)
35
+ stderr.should be_empty
18
36
  exit_status.should be_success
19
- stdout.should =~ %r{(foo:s1 s10|s10 foo:s1)}
20
37
  end
21
38
  end
22
39
 
@@ -21,8 +21,9 @@ feature "Config DSL" do
21
21
  CONFIG
22
22
 
23
23
  run "taketo slots:staging --dry-run"
24
- exit_status.should be_success
25
24
  stdout.should =~ %r{ssh -t 1.2.3.4 "(RAILS_ENV=staging FOO=bar|FOO=bar RAILS_ENV=staging) bash"}
25
+ stderr.should be_empty
26
+ exit_status.should be_success
26
27
  end
27
28
 
28
29
  scenario "Command" do
@@ -41,8 +42,9 @@ feature "Config DSL" do
41
42
  CONFIG
42
43
 
43
44
  run "taketo slots:staging --dry-run --command console"
44
- exit_status.should be_success
45
45
  stdout.should == %Q{ssh -t 1.2.3.4 "cd /var/apps/slots; RAILS_ENV=staging rails c"}
46
+ stderr.should be_empty
47
+ exit_status.should be_success
46
48
  end
47
49
 
48
50
  context "Default command" do
@@ -70,14 +72,16 @@ feature "Config DSL" do
70
72
 
71
73
  scenario "Explicit default command" do
72
74
  run "taketo slots:staging:s1 --dry-run"
73
- exit_status.should be_success
74
75
  stdout.should == %q{ssh -t 1.2.3.4 "RAILS_ENV=staging rails c"}
76
+ stderr.should be_empty
77
+ exit_status.should be_success
75
78
  end
76
79
 
77
80
  scenario "Default command defined in config" do
78
81
  run "taketo slots:staging:s2 --dry-run"
79
- exit_status.should be_success
80
82
  stdout.should == %q{ssh -t 2.3.4.5 "RAILS_ENV=staging tmux attach || tmux new-session"}
83
+ stderr.should be_empty
84
+ exit_status.should be_success
81
85
  end
82
86
  end
83
87
 
@@ -94,8 +98,9 @@ feature "Config DSL" do
94
98
  CONFIG
95
99
 
96
100
  run "taketo --dry-run"
97
- exit_status.should be_success
98
101
  stdout.should == %q{ssh -t 1.2.3.4 "cd /var/foo; RAILS_ENV=staging bash"}
102
+ stderr.should be_empty
103
+ exit_status.should be_success
99
104
  end
100
105
 
101
106
  context "Per-Scope default server config" do
@@ -127,13 +132,16 @@ feature "Config DSL" do
127
132
 
128
133
  scenario "Global default server config" do
129
134
  run "taketo shoes --dry-run"
130
- exit_status.should be_success
131
135
  stdout.should =~ /ssh -t 2\.3\.4\.5 "(RAILS_ENV=production FOO=bar|FOO=bar RAILS_ENV=production) bash"/
136
+ stderr.should be_empty
137
+ exit_status.should be_success
132
138
  end
133
139
 
134
140
  scenario "Project default server config" do
135
141
  run "taketo slots --dry-run"
136
142
  stdout.should =~ /ssh -t 1\.2\.3\.4 "cd .mnt.apps; (RAILS_ENV=staging FOO=bar|FOO=bar RAILS_ENV=staging) bash"/
143
+ stderr.should be_empty
144
+ exit_status.should be_success
137
145
  end
138
146
  end
139
147
 
@@ -156,8 +164,9 @@ feature "Config DSL" do
156
164
  CONFIG
157
165
 
158
166
  run "taketo slots:staging:s1 --dry-run"
159
- exit_status.should be_success
160
167
  stdout.should == %q{ssh -t -p 9999 1.2.3.4 "cd /var/qux; RAILS_ENV=staging bash"}
168
+ stderr.should be_empty
169
+ exit_status.should be_success
161
170
  end
162
171
 
163
172
  scenario "Shared server config with arguments" do
@@ -181,8 +190,9 @@ feature "Config DSL" do
181
190
  CONFIG
182
191
 
183
192
  run "taketo slots:staging:s1 --dry-run"
184
- exit_status.should be_success
185
193
  stdout.should == %q{ssh -t -p 9999 1.2.3.4 "cd /var/qux; RAILS_ENV=staging bash"}
194
+ stderr.should be_empty
195
+ exit_status.should be_success
186
196
  end
187
197
  end
188
198
 
@@ -200,8 +210,9 @@ feature "Config DSL" do
200
210
  CONFIG
201
211
 
202
212
  run "taketo --dry-run"
203
- exit_status.should be_success
204
213
  stdout.should =~ %r{ssh -t 1.2.3.4 "cd /var/apps/slots; (RAILS_ENV=staging FOO=the\\ value|FOO=the\\ value RAILS_ENV=staging) bash"}
214
+ stderr.should be_empty
215
+ exit_status.should be_success
205
216
  end
206
217
 
207
218
  scenario "Unique server alias" do
@@ -221,8 +232,9 @@ feature "Config DSL" do
221
232
  CONFIG
222
233
 
223
234
  run "taketo ss2 --dry-run"
224
- exit_status.should be_success
225
235
  stdout.should == %q{ssh -t 2.3.4.5 "RAILS_ENV=staging bash"}
236
+ stderr.should be_empty
237
+ exit_status.should be_success
226
238
  end
227
239
 
228
240
  scenario "Default destination" do
@@ -241,8 +253,9 @@ feature "Config DSL" do
241
253
  CONFIG
242
254
 
243
255
  run "taketo --dry-run"
244
- exit_status.should be_success
245
256
  stdout.should == %Q{ssh -t 2.3.4.5 "RAILS_ENV=staging bash"}
257
+ stderr.should be_empty
258
+ exit_status.should be_success
246
259
  end
247
260
 
248
261
  scenario "ssh identity file" do
@@ -258,8 +271,9 @@ feature "Config DSL" do
258
271
  CONFIG
259
272
 
260
273
  run "taketo --dry-run"
261
- exit_status.should be_success
262
274
  stdout.should == %q{ssh -t -i /home/gor/.ssh/foo\ bar 2.3.4.5 "RAILS_ENV=staging bash"}
275
+ stderr.should be_empty
276
+ exit_status.should be_success
263
277
  end
264
278
 
265
279
  scenario "server outside project" do
@@ -270,8 +284,55 @@ feature "Config DSL" do
270
284
  CONFIG
271
285
 
272
286
  run "taketo my_server --dry-run"
273
- exit_status.should be_success
274
287
  stdout.should == %q{ssh -t 1.2.3.4 "bash"}
288
+ stderr.should be_empty
289
+ exit_status.should be_success
275
290
  end
276
291
 
292
+ scenario "group at project level" do
293
+ create_config <<-CONFIG
294
+ project :slots do
295
+ group :frontends do
296
+ server :s1 do
297
+ host '1.2.3.4'
298
+ end
299
+
300
+ server :s2 do
301
+ host '2.3.4.5'
302
+ end
303
+ end
304
+
305
+ server :s3 do
306
+ host '3.4.5.6'
307
+ end
308
+ end
309
+ CONFIG
310
+
311
+ run "taketo --list slots:frontends"
312
+ stdout.should == "slots:frontends:s1\nslots:frontends:s2"
313
+ stderr.should be_empty
314
+ exit_status.should be_success
315
+ end
316
+
317
+ scenario "groups at config level" do
318
+ create_config <<-CONFIG
319
+ group :beer do
320
+ server do
321
+ host '1.2.3.4'
322
+ end
323
+ end
324
+
325
+ project :bars do
326
+ server do
327
+ host '3.4.5.6'
328
+ end
329
+ end
330
+ CONFIG
331
+
332
+ run "taketo --list beer"
333
+ stdout.should == "beer:default"
334
+ stderr.should be_empty
335
+ exit_status.should be_success
336
+ end
277
337
  end
338
+
@@ -6,8 +6,8 @@ feature "Config validation" do
6
6
  CONFIG
7
7
 
8
8
  run "taketo"
9
- exit_status.should_not be_success
10
9
  stderr.should include("There are no servers. Add some to your config (~/.taketo.rc.rb by default)")
10
+ exit_status.should_not be_success
11
11
  end
12
12
 
13
13
  scenario "Project has no servers" do
@@ -25,8 +25,23 @@ feature "Config validation" do
25
25
  CONFIG
26
26
 
27
27
  run "taketo"
28
- exit_status.should_not be_success
29
28
  stderr.should include("Project foo: no servers")
29
+ exit_status.should_not be_success
30
+ end
31
+
32
+ scenario "Group has no servers" do
33
+ create_config <<-CONFIG
34
+ server do
35
+ host '1.2.3.4'
36
+ end
37
+
38
+ group :testgroup do
39
+ end
40
+ CONFIG
41
+
42
+ run "taketo"
43
+ stderr.should include("Group testgroup: no servers")
44
+ exit_status.should_not be_success
30
45
  end
31
46
 
32
47
  scenario "Server has no host defined" do
@@ -40,8 +55,8 @@ feature "Config validation" do
40
55
  CONFIG
41
56
 
42
57
  run "taketo"
43
- exit_status.should_not be_success
44
58
  stderr.should include("Server foo:bar:default: host is not defined")
59
+ exit_status.should_not be_success
45
60
  end
46
61
 
47
62
  scenario "Duplicate global server alias" do
@@ -62,8 +77,8 @@ feature "Config validation" do
62
77
  CONFIG
63
78
 
64
79
  run "taketo"
65
- exit_status.should_not be_success
66
80
  stderr.should include("Server foo:bar:s2: global alias 'a1' has already been taken by server foo:bar:s1")
81
+ exit_status.should_not be_success
67
82
  end
68
83
 
69
84
  scenario "Command without definition" do
@@ -81,8 +96,8 @@ feature "Config validation" do
81
96
  CONFIG
82
97
 
83
98
  run "taketo"
84
- exit_status.should_not be_success
85
99
  stderr.should include("Don't know what to execute on command qux")
100
+ exit_status.should_not be_success
86
101
  end
87
102
  end
88
103
 
@@ -19,8 +19,9 @@ feature "connect to server" do
19
19
  CONFIG
20
20
 
21
21
  run "taketo slots:staging:s1 --dry-run"
22
- exit_status.should be_success
23
22
  stdout.should == %Q{ssh -t deployer@1.2.3.4 "cd /var/apps/slots; RAILS_ENV=staging bash"}
23
+ stderr.should be_empty
24
+ exit_status.should be_success
24
25
  end
25
26
 
26
27
  scenario "ssh to the only server" do
@@ -36,8 +37,9 @@ feature "connect to server" do
36
37
  CONFIG
37
38
 
38
39
  run "taketo --dry-run"
39
- exit_status.should be_success
40
40
  stdout.should == %Q{ssh -t 1.2.3.4 "cd /var/apps/slots; RAILS_ENV=staging bash"}
41
+ stderr.should be_empty
42
+ exit_status.should be_success
41
43
  end
42
44
 
43
45
  scenario "ssh without password" do
@@ -53,8 +55,9 @@ feature "connect to server" do
53
55
  CONFIG
54
56
 
55
57
  run "taketo --dry-run"
56
- exit_status.should be_success
57
58
  stdout.should == %q{ssh -t -i /home/gor/.ssh/foo\ bar 2.3.4.5 "RAILS_ENV=staging bash"}
59
+ stderr.should be_empty
60
+ exit_status.should be_success
58
61
  end
59
62
  end
60
63
 
@@ -18,14 +18,14 @@ feature "Resolve host error handling" do
18
18
 
19
19
  scenario "Non-existent location" do
20
20
  run "taketo slots:staging:qqq --dry-run"
21
+ stderr.should include("Can't find such destination: slots:staging:qqq")
21
22
  exit_status.should_not be_success
22
- stderr.should include("Can't find server for path slots:staging:qqq")
23
23
  end
24
24
 
25
25
  scenario "Ambiguous location" do
26
26
  run "taketo slots:staging --dry-run"
27
- exit_status.should_not be_success
28
27
  stderr.should include("There are multiple possible destinations: slots:staging:s1, slots:staging:s2")
28
+ exit_status.should_not be_success
29
29
  end
30
30
  end
31
31
 
@@ -25,7 +25,6 @@ feature "Generate SSH config" do
25
25
 
26
26
  scenario "Generate ssh config" do
27
27
  run "taketo --generate-ssh-config"
28
- exit_status.should be_success
29
28
  stdout.should == <<-SSH_CONFIG.chomp
30
29
  Host bar.foo.com
31
30
  Hostname bar.foo.com
@@ -39,6 +38,7 @@ Hostname 2.3.4.5
39
38
  Host 2.3.4.5
40
39
  Hostname 2.3.4.5
41
40
  SSH_CONFIG
41
+ exit_status.should be_success
42
42
  end
43
43
  end
44
44
 
@@ -2,6 +2,8 @@ require 'acceptance_spec_helper'
2
2
 
3
3
  feature "Global server alias" do
4
4
  background { config_exists <<-CONFIG }
5
+ default_destination 'foo:bar'
6
+
5
7
  project :foo do
6
8
  environment :bar do
7
9
  server do
@@ -32,7 +34,6 @@ feature "Global server alias" do
32
34
 
33
35
  scenario "Unique server alias" do
34
36
  run "taketo --view"
35
- exit_status.should be_success
36
37
  stdout.should == <<-CONFIG_OUTLINE.chomp
37
38
 
38
39
  Project: foo
@@ -55,11 +56,11 @@ Project: baz
55
56
  console
56
57
  killall - Kill ALL humans
57
58
  CONFIG_OUTLINE
59
+ exit_status.should be_success
58
60
  end
59
61
 
60
62
  scenario "View particular server config" do
61
63
  run "taketo foo:bar:default --view"
62
- exit_status.should be_success
63
64
  stdout.should == <<-CONFIG_OUTLINE.chomp
64
65
  Server: default
65
66
  Host: 1.2.3.4
@@ -69,6 +70,7 @@ Server: default
69
70
  Default command: bash
70
71
  Environment: RAILS_ENV=bar
71
72
  CONFIG_OUTLINE
73
+ exit_status.should be_success
72
74
  end
73
75
  end
74
76
 
@@ -14,8 +14,9 @@ feature "Location on remote host" do
14
14
  CONFIG
15
15
 
16
16
  run "taketo slots:staging --dry-run --directory /var/www"
17
- exit_status.should be_success
18
17
  stdout.should == %q{ssh -t 1.2.3.4 "cd /var/www; RAILS_ENV=staging bash"}
18
+ stderr.should be_empty
19
+ exit_status.should be_success
19
20
  end
20
21
  end
21
22
 
@@ -19,7 +19,7 @@ module AcceptanceSpecDSL
19
19
  alias :scenario :it
20
20
  alias :xscenario :xit
21
21
  alias :given :let
22
- alias :given! :let!
22
+ alias :given! :let
23
23
  end
24
24
  end
25
25
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'taketo/actions'
3
+
4
+ include Taketo
5
+
6
+ describe "Actions" do
7
+ describe ".action_by_name" do
8
+ it "returns class by name" do
9
+ Actions[:matches].should == Actions::Matches
10
+ end
11
+
12
+ it "returns LoginAction if action was not found" do
13
+ Actions[:never_existed_here].should == Actions::Login
14
+ end
15
+ end
16
+ end
17
+