Sha256: ba1d29744a3d4e3582bbacb148c46bdb9c2c02a18e4798f0d8e6b200845627c7

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

module OpalSpec
  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

2 entries across 2 versions & 1 rubygems

Version Path
opal-spec-0.0.2 lib/opal/spec/example.rb
opal-spec-0.0.1 lib/opal/spec/example.rb