Permalink
Browse files

print error message if no core is found.

  • Loading branch information...
1 parent 98e5253 commit b7900ba652da28fc608fbfe0b66002e9d0cb7eae @achiu committed Oct 10, 2011
Showing with 22 additions and 10 deletions.
  1. +6 −1 lib/consular/cli.rb
  2. +2 −9 lib/consular/dsl.rb
  3. +14 −0 spec/cli_spec.rb
View
7 lib/consular/cli.rb
@@ -146,7 +146,12 @@ def delete(project = nil)
#
# @api private
def valid_core
- Consular.cores.detect { |core| core.valid_system? }
+ core = Consular.cores.detect { |core| core.valid_system? }
+ unless core
+ say "No valid core was found!. Exiting...", :red
+ raise SystemExit
+ end
+ core
end
# Returns the first comment in file. This is used
# as the title when listing out the scripts.
View
11 lib/consular/dsl.rb
@@ -184,22 +184,15 @@ def run_context(context, &block)
@_context = @_old_context
end
- def clean_up_context(context = last_open_window, old_context = nil)
- @_context = context
- @_old_context = old_context
- end
-
- def last_open_window
- @_windows[@_windows.keys.last]
- end
-
# Return the default hash format for windows
#
# @api private
def window_hash
{:tabs => {'default' =>{:commands=>[]}}}.dup
end
+ # Contains interpretation for the legacy YAML format.
+ #
module Yaml
# Returns yaml file as formmatted hash
#
View
14 spec/cli_spec.rb
@@ -71,6 +71,13 @@ def setup!; puts('setup'); end
output = capture_io { Consular::CLI.start ['start', 'barr'] }.join('')
assert_match /does not exist/, output
end
+
+ it "should SystemExit if no core can be found" do
+ Consular.instance_variable_set(:@cores,[])
+ assert_raises SystemExit do
+ capture_io { Consular::CLI.start ['start', 'foo'] }.join('')
+ end
+ end
end
describe "setup command" do
@@ -101,6 +108,13 @@ def setup!; puts('setup'); end
output = capture_io { Consular::CLI.start ['setup', 'barr'] }.join('')
assert_match /does not exist/, output
end
+
+ it "should SystemExit if no core can be found" do
+ Consular.instance_variable_set(:@cores,[])
+ assert_raises SystemExit do
+ capture_io { Consular::CLI.start ['setup', 'foo'] }.join('')
+ end
+ end
end
it "init creates a new global script directory and consularc" do

0 comments on commit b7900ba

Please sign in to comment.