Sha256: 37cf47344d0b635c7a114871728c1bd16960cf774607d641b0a64e1107f8de3d
Contents?: true
Size: 1.88 KB
Versions: 15
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' describe RailsWizard::Template do subject{ RailsWizard::Template } let(:recipe){ RailsWizard::Recipe.generate('name','# test') } describe '#initialize' do it 'should work with classes' do subject.new([recipe]).recipes.should == [recipe] end end describe '#resolve_dependencies' do def recipe(name, opts={}) RailsWizard::Recipe.generate(name, '', opts) end subject do @template = RailsWizard::Template.new([]) @template.stub!(:recipes_with_dependencies).and_return(@recipes) @template.resolve_recipes.map { |r| r.key } end it 'should sort properly' do @recipes = [ recipe('add_user', :run_after => ['devise']), recipe('devise', :run_after => ['omniauth']), recipe('omniauth'), recipe('haml'), recipe('compass') ] subject.index('devise').should > subject.index('omniauth') end end describe '#recipes_with_dependencies' do def r(*deps) mock(:Class, :requires => deps, :superclass => RailsWizard::Recipe) end subject do @template = RailsWizard::Template.new([]) @template.stub!(:recipes).and_return(@recipes) @template.stub!(:recipe_classes).and_return(@recipes) @template end it 'should return the same number recipes if none have dependencies' do @recipes = [r, r] subject.recipes_with_dependencies.size.should == 2 end it 'should handle simple dependencies' do @recipes = [r(r, r), r(r)] subject.recipes_with_dependencies.size.should == 5 end it 'should handle multi-level dependencies' do @recipes = [r(r(r))] subject.recipes_with_dependencies.size.should == 3 end it 'should uniqify' do a = r b = r(a) c = r(r, a, b) @recipes = [a,b,c] subject.recipes_with_dependencies.size.should == 4 end end end
Version data entries
15 entries across 15 versions & 1 rubygems