Improve Env constructor
This commit is contained in:
parent
a3bba6d4da
commit
8e455fc4d5
@ -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
|
||||
|
@ -2,20 +2,28 @@ 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
|
||||
|
||||
context 'without argument' do
|
||||
it 'has no recipe' do
|
||||
expect(env.current_recipe).not_to be
|
||||
end
|
||||
end
|
||||
|
||||
describe '#current_recipe' do
|
||||
it 'returns the assigned current recipe' do
|
||||
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
|
||||
|
||||
describe '#target' do
|
||||
let(:target) { Object.new }
|
||||
|
Loading…
x
Reference in New Issue
Block a user