Class: RSpec::Jasmine::Example

Inherits:
Core::Example
  • Object
show all
Defined in:
lib/rspec/jasmine/example.rb

Instance Method Summary collapse

Instance Method Details

#run(example_group_instance, reporter) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rspec/jasmine/example.rb', line 8

def run(example_group_instance, reporter)
  @example_group_instance = example_group_instance
  @example_group_instance.example = self

  start(reporter)

  begin
    unless pending
      begin
        @example_group_instance.instance_eval(&@example_block)
        @result = @example_group_instance.instance_variable_get('@result')
        @result.scream! if @result
      rescue RSpec::Core::Pending::PendingDeclaredInExample => e
        @pending_declared_in_example = e.message
      rescue Exception => e
        set_exception(e)
      end
    end
  rescue Exception => e
    set_exception(e)
  ensure
    @example_group_instance.instance_variables.each do |ivar|
      @example_group_instance.instance_variable_set(ivar, nil)
    end
    @example_group_instance = nil

    begin
      assign_generated_description
    rescue Exception => e
      set_exception(e, "while assigning the example description")
    end
  end

  class << self.
    def location
      caller.find { |x| x =~ /\<top \(required\)\>/ }.split(/\:\d+\:in/)[0]
    end
  end
  
  @result.merge_backtrace_with!(exception) if exception
  finish(reporter)
end