rake support

This commit is contained in:
John Bintz 2011-08-31 14:11:05 -04:00
parent c4407f1690
commit b4e79b5daa
2 changed files with 37 additions and 0 deletions

View File

@ -11,6 +11,18 @@ module Penchant
def run(env = nil)
instance_eval(File.read('.penchant'))
end
def rake(*tasks)
command = [ "rake", *tasks ]
command.unshift("bundle exec") if gemfile?
Kernel.system command.join(' ')
end
private
def gemfile?
File.file?('Gemfile')
end
end
end

View File

@ -16,5 +16,30 @@ describe Penchant::DotPenchant do
dot_file.instance_variable_get(:@did_run).should == :this
end
end
let(:dot_file) { described_class.new }
describe '#rake' do
context 'without Gemfile' do
before do
Kernel.expects(:system).with('rake task1 task2')
end
it 'should run the rake task via system' do
dot_file.rake("task1", "task2")
end
end
context 'with Gemfile' do
before do
File.open('Gemfile', 'wb')
Kernel.expects(:system).with('bundle exec rake task1 task2')
end
it 'should run the rake task via system' do
dot_file.rake("task1", "task2")
end
end
end
end