Sha256: 2ceb51eac67bbc4a35dab6360a800adce043eb1429db98518befe0fc70863f60

Contents?: true

Size: 700 Bytes

Versions: 5

Compression:

Stored size: 700 Bytes

Contents

module Spec
  module DSL
    class BehaviourFactory

      class << self

        BEHAVIOUR_CLASSES = {:default => Spec::DSL::Behaviour}
        
        def add_behaviour_class(key, value)
          BEHAVIOUR_CLASSES[key] = value
        end

        def remove_behaviour_class(key)
          BEHAVIOUR_CLASSES.delete(key)
        end

        def create(*args, &block)
          return BEHAVIOUR_CLASSES[behaviour_type(*args)].new(*args, &block)
        end
        
      private
      
        def behaviour_type(*args)
          opts = Hash === args.last ? args.last : {}
          opts[:behaviour_type] ? opts[:behaviour_type] : :default
        end
        
      end
      
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspec-0.9.1 lib/spec/dsl/behaviour_factory.rb
rspec-0.9.0 lib/spec/dsl/behaviour_factory.rb
rspec-0.9.2 lib/spec/dsl/behaviour_factory.rb
rspec-0.9.3 lib/spec/dsl/behaviour_factory.rb
rspec-0.9.4 lib/spec/dsl/behaviour_factory.rb