diff --git a/app/controller/preferences_controller.rb b/app/controller/preferences_controller.rb index e486642..6135b1c 100644 --- a/app/controller/preferences_controller.rb +++ b/app/controller/preferences_controller.rb @@ -57,7 +57,7 @@ def showPathErrorAlert(notification) alert = NSAlert.alloc.init alert.alertStyle = OSX::NSCriticalAlertStyle - alert.messageText = "The path '#{path}' doesn't exist.." + alert.messageText = "The executable path '#{path}' doesn't exist.\nPlease check your preferences." alert.runModal end end \ No newline at end of file diff --git a/app/controller/window_controller.rb b/app/controller/window_controller.rb index 66151b7..fca2233 100644 --- a/app/controller/window_controller.rb +++ b/app/controller/window_controller.rb @@ -13,6 +13,7 @@ def awakeFromNib def runSpecs(sender) return if SpecRunner.command_running? + return unless valid_bin_paths? path = @pathTextField.stringValue return false if path.empty? || !File.exist?(path) specRunPreparation(nil) @@ -92,6 +93,13 @@ def path_is_valid?(path) end end + def valid_bin_paths? + return false unless $app.file_exist?($app.default_from_key(:spec_bin_path)) + return false unless $app.file_exist?($app.default_from_key(:ruby_bin_path)) + return false unless $app.file_exist?($app.default_from_key(:tm_bin_path)) + true + end + def hook_events receive :spec_run_invoked, :specRunPreparation receive :spec_run_start, :specRunStarted diff --git a/spec/controller/window_controller_spec.rb b/spec/controller/window_controller_spec.rb index 3164dbf..37d389a 100644 --- a/spec/controller/window_controller_spec.rb +++ b/spec/controller/window_controller_spec.rb @@ -40,6 +40,8 @@ $app = mock('App') $app.stub!(:default_for_key) + $app.stub!(:default_from_key) + $app.stub!(:file_exist?).and_return(true) $spec_list = SpecList.new SpecRunner.stub!(:run_in_path).and_return(File.dirname(__FILE__)) end @@ -163,4 +165,14 @@ @mock_statusLabel.should_receive(:stringValue=).with('') @controller.path_is_valid?('/tmp').should be_true end + + it 'should check valid bin paths before running a spec' do + @controller.should_receive(:valid_bin_paths?) + @controller.runSpecs(nil) + end + + it 'should check all 3 bin paths before spec run' do + $app.should_receive(:file_exist?).and_return(false) + @controller.valid_bin_paths?.should be_false + end end \ No newline at end of file