Sha256: 7d5e1c394a426bb2a0946e122f6380c055e51d5c6efc5ba382fd1ce2bf05be23

Contents?: true

Size: 1.24 KB

Versions: 48

Compression:

Stored size: 1.24 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 '#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

48 entries across 48 versions & 4 rubygems

Version Path
ey_rails_wizard-0.3.1 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.2.1 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.2.0 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.8 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.7 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.6 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.5 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.4 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.3 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.2 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.1 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.1.0 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.26 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.25 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.24 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.23 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.22 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.21 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.20 spec/rails_wizard/template_spec.rb
rails_apps_composer-1.0.19 spec/rails_wizard/template_spec.rb