Improve Env constructor
This commit is contained in:
parent
a3bba6d4da
commit
8e455fc4d5
@ -4,7 +4,7 @@ module Producer
|
|||||||
attr_reader :current_recipe
|
attr_reader :current_recipe
|
||||||
attr_accessor :target
|
attr_accessor :target
|
||||||
|
|
||||||
def initialize(recipe)
|
def initialize(recipe = nil)
|
||||||
@current_recipe = recipe
|
@current_recipe = recipe
|
||||||
@target = nil
|
@target = nil
|
||||||
end
|
end
|
||||||
|
@ -2,18 +2,26 @@ require 'spec_helper'
|
|||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Env do
|
describe Env do
|
||||||
let(:recipe) { Recipe.new(proc { nil }) }
|
subject(:env) { Env.new }
|
||||||
subject(:env) { Env.new(recipe) }
|
|
||||||
|
|
||||||
describe '#initialize' do
|
describe '#initialize' do
|
||||||
it 'has no target' do
|
it 'has no target' do
|
||||||
expect(env.target).not_to be
|
expect(env.target).not_to be
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
describe '#current_recipe' do
|
context 'without argument' do
|
||||||
it 'returns the assigned current recipe' do
|
it 'has no recipe' do
|
||||||
expect(env.current_recipe).to eq recipe
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user