diff --git a/lib/bake/context.rb b/lib/bake/context.rb index 1e1e33e..a3ad739 100644 --- a/lib/bake/context.rb +++ b/lib/bake/context.rb @@ -5,6 +5,7 @@ # Copyright, 2020, by Olle Jonsson. require_relative 'base' +require_relative 'registry' module Bake # The default file name for the top level bakefile. @@ -110,6 +111,8 @@ def lookup(command) @recipes[command] end + alias [] lookup + def to_s if @root "#{self.class} #{File.basename(@root)}" diff --git a/test/bake/context.rb b/test/bake/context.rb index 3d85cd9..8ca3197 100644 --- a/test/bake/context.rb +++ b/test/bake/context.rb @@ -10,7 +10,10 @@ let(:context) {subject.load(bakefile)} it 'can invoke root task' do - expect(context.lookup('doot')).to receive(:call) + recipe = context.lookup('doot') + + expect(recipe).to receive(:call) + expect(recipe.instance).to receive(:doot) context.call('doot') end