Sha256: 23d065fb035115b1a4a24b6ebd12110baad189f3ea800125042d7f5de222cb6a

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
ospec-0.1.15 lib/ospec/example.rb