Sha256: 6ea297c310db573048bd6f7f4a5be83831e212de9004a016f519aa6c73b95b48

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

class CustomFactory
  attr_accessor :name, :options

  def initialize name, options = {}
    @name, @options = [name, options]
  end  
end

shared_examples_for 'Factory' do
  describe 'configure factory' do
    describe 'set factory' do
      describe 'using non-callable' do
       it 'should not allow factory to be defined' do
          lambda { subject.factory {|name, opts| CustomFactory.new name, opts} }.should raise_error
        end
      end

      describe 'using lambda' do
        before :each do
          subject.factory lambda {|name, opts| CustomFactory.new name, opts}
        end

        it 'should set it' do
          subject.factory_build('hello', :works => true).name.should == 'hello'
        end
      end

      describe 'using Proc' do
        before :each do
          subject.factory Proc.new {|name, opts| CustomFactory.new name, opts}
        end

        it 'should set it' do
          subject.factory_build('hello', :works => true).name.should == 'hello'
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cantango-config-0.2.1 spec/cantango/config/shared/factory_ex.rb
cantango-config-0.2.0 spec/cantango/config/shared/factory_ex.rb
cantango-config-0.1.9.2 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.8.1 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.8 spec/cantango/configuration/shared/factory_ex.rb