rake support
This commit is contained in:
parent
c4407f1690
commit
b4e79b5daa
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user