Skip to content

Commit

Permalink
Merge pull request #82 from deees/fix/rake_files
Browse files Browse the repository at this point in the history
Treat rake files as ruby files
  • Loading branch information
mmozuras committed Sep 20, 2015
2 parents 0a21098 + 4c59cac commit 740e0c7
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, &: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 740e0c7

Please sign in to comment.