diff --git a/lib/producer/core/env.rb b/lib/producer/core/env.rb index 25adf51..76edb59 100644 --- a/lib/producer/core/env.rb +++ b/lib/producer/core/env.rb @@ -4,7 +4,7 @@ module Producer attr_reader :current_recipe attr_accessor :target - def initialize(recipe) + def initialize(recipe = nil) @current_recipe = recipe @target = nil end diff --git a/spec/producer/core/env_spec.rb b/spec/producer/core/env_spec.rb index 64354e9..5575852 100644 --- a/spec/producer/core/env_spec.rb +++ b/spec/producer/core/env_spec.rb @@ -2,18 +2,26 @@ require 'spec_helper' module Producer::Core describe Env do - let(:recipe) { Recipe.new(proc { nil }) } - subject(:env) { Env.new(recipe) } + subject(:env) { Env.new } describe '#initialize' do it 'has no target' do expect(env.target).not_to be end - end - describe '#current_recipe' do - it 'returns the assigned current recipe' do - expect(env.current_recipe).to eq recipe + context 'without argument' do + it 'has no recipe' do + expect(env.current_recipe).not_to be + end + end + + context 'when a recipe is given as argument' do + let(:recipe) { Recipe.new(proc { nil }) } + subject(:env) { Env.new(recipe) } + + it 'assigns the current recipe' do + expect(env.current_recipe).to eq recipe + end end end