Skip to content

Commit

Permalink
Bin path check just before spec run
Browse files Browse the repository at this point in the history
  • Loading branch information
rubyphunk committed Aug 18, 2008
1 parent 06471f7 commit bd1f90f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controller/preferences_controller.rb
Expand Up @@ -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
8 changes: 8 additions & 0 deletions app/controller/window_controller.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/controller/window_controller_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit bd1f90f

Please sign in to comment.