Skip to content

Commit

Permalink
Treat rake files as ruby files
Browse files Browse the repository at this point in the history
  • Loading branch information
deees committed Jun 19, 2015
1 parent ed9886e commit 4c59cac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/pronto/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
5 changes: 5 additions & 0 deletions spec/pronto/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 4c59cac

Please sign in to comment.