Sha256: 7431055f7cf5d90e95e18825a95e7cc946af1110919712f8d1013ae422940a3e

Contents?: true

Size: 883 Bytes

Versions: 9

Compression:

Stored size: 883 Bytes

Contents

module Spec
  class Example
    attr_reader :description, :example_group, :exception

    def initialize(group, desc, block)
      @example_group = group
      @description   = desc
      @__block__     = block
    end

    def run_before_hooks
      @example_group.before_hooks.each do |before|
        instance_eval &before
      end
    end

    def run_after_hooks
      @example_group.after_hooks.each do |after|
        instance_eval &after
      end
    end

    def run runner
      begin
        runner.example_started self
        run_before_hooks
        instance_eval &@__block__
      rescue => e
        @exception = e
      ensure
        begin
          run_after_hooks
        rescue => e
          @exception = e
        end
      end

      if @exception
        runner.example_failed self
      else
        runner.example_passed self
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
opal-spec-0.1.15 lib/opal/spec/example.rb
opal-spec-0.1.14 lib/opal/spec/example.rb
opal-spec-0.1.13 lib/opal/spec/example.rb
opal-spec-0.1.12 lib/opal/spec/example.rb
opal-spec-0.1.11 lib/opal/spec/example.rb
opal-spec-0.1.10 lib/opal/spec/example.rb
opal-spec-0.1.9 lib/opal/spec/example.rb
opal-spec-0.1.8 lib/opal/spec/example.rb
opal-spec-0.1.7 lib/opal/spec/example.rb