Sha256: 7ca46ef9b1923f37d9cfdfd40d71f12e1638f479679b4d68f428c90027f47b7f

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

module Testable
  module Factory
    # Creates a definition context for actions. If an existing context
    # exists, that context will be re-used.
    def on(definition, visit = false, &block)
      unless @context.is_a?(definition)
        @context = definition.new
        @context.view if visit
      end

      yield @context if block
      @context
    end

    # Creates a definition context for actions and establishes the
    # context for execution.
    def on_view(definition, &block)
      on(definition, true, &block)
    end

    alias on_visit on_view
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
testable-0.2.0 lib/testable/factory.rb