diff --git a/lib/producer/core/condition/dsl.rb b/lib/producer/core/condition/dsl.rb index 4131e32..9d0709c 100644 --- a/lib/producer/core/condition/dsl.rb +++ b/lib/producer/core/condition/dsl.rb @@ -24,7 +24,7 @@ module Producer end def evaluate - @block.call + instance_eval &@block end end end diff --git a/spec/producer/core/condition/dsl_spec.rb b/spec/producer/core/condition/dsl_spec.rb index adbdb4c..348e874 100644 --- a/spec/producer/core/condition/dsl_spec.rb +++ b/spec/producer/core/condition/dsl_spec.rb @@ -43,22 +43,6 @@ module Producer::Core it 'defines a new test keyword' do expect(dsl).to respond_to :some_test end - - context 'defined test keyword' do - let(:arguments) { [:some, :arguments] } - - it 'builds a new test with the env and given arguments' do - expect(some_test_class).to receive(:new).with(env, arguments) - dsl.some_test(arguments) - end - - it 'registers the new test' do - some_test = double('SomeTest instance') - allow(some_test_class).to receive(:new) { some_test } - dsl.some_test(arguments) - expect(dsl.tests).to include(some_test) - end - end end describe '#initialize' do @@ -86,6 +70,27 @@ module Producer::Core it 'returns the value returned by the assigned block' do expect(dsl.evaluate).to eq block.call end + + context 'when a defined test keyword is called' do + let(:some_test_class) { double('SomeTest class') } + let(:block) { proc { some_test :some, :args } } + + before do + Condition::DSL.define_test(:some_test, some_test_class) + end + + it 'builds a new test with the env and given arguments' do + expect(some_test_class).to receive(:new).with(env, :some, :args) + dsl.evaluate + end + + it 'registers the new test' do + some_test = double('SomeTest instance') + allow(some_test_class).to receive(:new) { some_test } + dsl.evaluate + expect(dsl.tests).to include(some_test) + end + end end end end