Sha256: aa236ee21d0309b955c3ed94e6587ac180a3d8247d53124c05440e71dc00369c

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Picky::Generators::Selector do
  
  describe "main class" do
    before(:each) do
      @selector = Picky::Generators::Selector.new
    end
    
    describe "generator_for_class" do
      it "should return me a generator for the given class" do
        @selector.generator_for_class(Picky::Generators::Server::Classic, :identifier, :some_args).should be_kind_of(Picky::Generators::Server::Classic)
      end
    end
    
    describe "generator_for" do
      it "should not raise if a generator is available" do
        lambda { @selector.generator_for('sinatra_client', 'some_project') }.should_not raise_error
      end
      it "should not raise if a generator is available" do
        lambda { @selector.generator_for('classic_server', 'some_project') }.should_not raise_error
      end
      it "should not raise if a generator is available" do
        lambda { @selector.generator_for('sinatra_server', 'some_project') }.should_not raise_error
      end
      it "should raise if a generator is not available" do
        lambda { @selector.generator_for('blarf', 'gnorf') }.should raise_error(Picky::Generators::NotFoundException)
      end
    end
    
    describe "generate" do
      it "should raise a NoGeneratorException if called with the wrong params" do
        lambda { @selector.generate('blarf', 'gnorf') }.should raise_error(Picky::Generators::NotFoundException)
      end
      it "should not raise on the right params" do
        @selector.stub! :generator_for_class => stub(:generator, :generate => nil)
        
        lambda { @selector.generate('sinatra_client', 'some_project') }.should_not raise_error
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picky-generators-3.0.0.pre3 spec/lib/picky-generators/generators/selector_spec.rb
picky-generators-3.0.0.pre2 spec/lib/picky-generators/generators/selector_spec.rb