Sha256: 650a4b83751199c439add4c65bde5b061e94da1170342e64eda5d1b51a551697

Contents?: true

Size: 1 KB

Versions: 30

Compression:

Stored size: 1 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

30 entries across 30 versions & 2 rubygems

Version Path
cantango-config-0.1.7 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.6 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.5 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.4 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.3 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.2 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.1 spec/cantango/configuration/shared/factory_ex.rb
cantango-config-0.1.0 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.4.7 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.4.6 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.4.5 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.4.3 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.4.2 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.4.1 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.4 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.9.3.2 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.8.9.5 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.8.9.4 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.8.9.3 spec/cantango/configuration/shared/factory_ex.rb
cantango-0.8.9.2 spec/cantango/configuration/shared/factory_ex.rb