Implement source keyword feature for recipes
This commit is contained in:
parent
65643e065e
commit
c7295fb977
@ -8,3 +8,16 @@ Feature: recipe evaluation
|
||||
When I execute the recipe
|
||||
Then the exit status must be 0
|
||||
And the output must contain "hello from recipe"
|
||||
|
||||
Scenario: source keyword, requires a recipe file
|
||||
Given a recipe with:
|
||||
"""
|
||||
source 'sourced_recipe'
|
||||
"""
|
||||
And a file named "sourced_recipe.rb" with:
|
||||
"""
|
||||
puts 'sourced recipe'
|
||||
"""
|
||||
When I execute the recipe
|
||||
Then the exit status must be 0
|
||||
And the output must contain "sourced recipe"
|
||||
|
@ -24,6 +24,13 @@ module Producer
|
||||
instance_eval &block
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def source(filepath)
|
||||
instance_eval File.read("./#{filepath}.rb")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
1
spec/fixtures/recipes/error.rb
vendored
Normal file
1
spec/fixtures/recipes/error.rb
vendored
Normal file
@ -0,0 +1 @@
|
||||
raise 'error from recipe'
|
@ -45,6 +45,15 @@ module Producer::Core
|
||||
expect { dsl }.to raise_error(RuntimeError, 'error from recipe')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#source' do
|
||||
let(:code) { "source '#{fixture_path_for 'recipes/error'}'" }
|
||||
let(:dsl) { Recipe::DSL.new code }
|
||||
|
||||
it 'evaluates its code' do
|
||||
expect { dsl }.to raise_error(RuntimeError, 'error from recipe')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user