From 4c59cacdae79fa02e21df0ec8c281deb51fa416a Mon Sep 17 00:00:00 2001 From: Tomas Brazys Date: Fri, 19 Jun 2015 11:43:42 +0300 Subject: [PATCH] Treat rake files as ruby files --- lib/pronto/runner.rb | 10 +++++++++- spec/pronto/runner_spec.rb | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/pronto/runner.rb b/lib/pronto/runner.rb index fc90915d..2fd4833e 100644 --- a/lib/pronto/runner.rb +++ b/lib/pronto/runner.rb @@ -7,11 +7,19 @@ def self.runners end def ruby_file?(path) - File.extname(path) == '.rb' || ruby_executable?(path) + rb_file?(path) || rake_file?(path) || ruby_executable?(path) end private + def rb_file?(path) + File.extname(path) == '.rb' + end + + def rake_file?(path) + File.extname(path) == '.rake' + end + def ruby_executable?(path) line = File.open(path) { |file| file.readline } line =~ /#!.*ruby/ diff --git a/spec/pronto/runner_spec.rb b/spec/pronto/runner_spec.rb index 45a09b96..05ee481e 100644 --- a/spec/pronto/runner_spec.rb +++ b/spec/pronto/runner_spec.rb @@ -17,6 +17,11 @@ module Pronto it { should be_truthy } end + context 'ending with .rake' do + let(:path) { 'test.rake' } + it { should be_truthy } + end + context 'executable' do let(:path) { 'test' } before { File.stub(:open).with(path).and_return(shebang) }