Improve Recipe spec:

* Fix coding standards;
* Add spec for default assigned filepath;
* Add spec for #filepath accessor;
* Test object identity in #code spec.
This commit is contained in:
Thibault Jouan 2013-08-06 20:39:17 +00:00
parent 29563f6cc6
commit 22ae12185d

View File

@ -8,7 +8,7 @@ module Producer::Core
subject(:recipe) { Recipe.new(code) } subject(:recipe) { Recipe.new(code) }
describe '.from_file' do describe '.from_file' do
let (:filepath) { fixture_path_for 'recipes/empty.rb' } let(:filepath) { fixture_path_for 'recipes/empty.rb' }
subject(:recipe) { Recipe.from_file(filepath) } subject(:recipe) { Recipe.from_file(filepath) }
it 'builds a recipe whose code is read from given file path' do it 'builds a recipe whose code is read from given file path' do
@ -21,14 +21,23 @@ module Producer::Core
end end
describe '#initialize' do describe '#initialize' do
it 'builds a recipe' do it 'assigns nil as a default filepath' do
expect(recipe).to be_a Recipe expect(recipe.filepath).to be nil
end end
end end
describe '#code' do describe '#code' do
it 'returns the assigned code' do it 'returns the assigned code' do
expect(recipe.code).to eq code expect(recipe.code).to be code
end
end
describe '#filepath' do
let(:filepath) { 'some_file_path' }
let(:recipe) { Recipe.new(code, filepath) }
it 'returns the assigned file path' do
expect(recipe.filepath).to eq filepath
end end
end end