Class: RSpec::Core::Example

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/example.rb

Instance Method Summary collapse

Instance Method Details

#run(example_group_instance, reporter) ⇒ Object



3
4
5
6
7
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rspec/core/example.rb', line 3

def run(example_group_instance, reporter)
  @example_group_instance = example_group_instance
  @reporter = reporter
  RSpec.configuration.configure_example(self, hooks)
  RSpec.current_example = self

  start(reporter)
  Pending.mark_pending!(self, pending) if pending?

  begin
    if skipped?
      Pending.mark_pending! self, skip
    elsif !RSpec.configuration.dry_run?
      with_around_and_singleton_context_hooks do
        begin
          # NOTE Code is overrided HERE
          # Check if there are services or not 
          if self.[:services] != nil && self.[:services].is_a?(Array) && ENV["LUCIAN_DOCKER"] == nil
            result = run_lucian_test
            if result[2].to_i != 0
              pending_cut = result[0].join("\n").gsub("\n", "--_n").match(/(PENDING.*)FAILING/)[0] rescue nil
              failing_cut = result[0].join("\n").gsub("\n", "--_n").match(/(FAILING.*)Finished/)[0] rescue nil
              unless pending_cut.nil? # Pending present?
                # TODO Add pending logic here
              end
              unless failing_cut.nil? # Failing present?
                failing_cases = failing_cut.scan(/\|=:.*:=\|/)
                failing_cases.each do |_case|
                  data_cases = _case.split(":=|").collect{|message|
                    message.gsub("|=:","").split(":|-|:").collect{|_em| 
                      _em.gsub("--_n", "\n")
                    }
                  }
                  data_cases.each do |to_report|
                    #description = to_report[0]
                    lines = to_report[1]
                    traces = to_report[2]
                    error = StandardError.new(traces)
                    error.set_backtrace([lines])
                    raise error
                  end
                end
              end
            end
          else
            run_before_example
            @example_group_instance.instance_exec(self, &@example_block)

            if pending?
              Pending.mark_fixed! self

              raise Pending::PendingExampleFixedError,
                    'Expected example to fail since it is pending, but it passed.',
                    [location]
            end
          end
        rescue Pending::SkipDeclaredInExample
          # no-op, required metadata has already been set by the `skip`
          # method.
        rescue AllExceptionsExcludingDangerousOnesOnRubiesThatAllowIt => e
          set_exception(e)
        ensure
          run_after_example
        end
      end
    end
  rescue Support::AllExceptionsExceptOnesWeMustNotRescue => e
    set_exception(e)
  ensure
    @example_group_instance = nil # if you love something... let it go
  end

  finish(reporter)
ensure
  execution_result.ensure_timing_set(clock)
  RSpec.current_example = nil
end

#run_lucian_testObject



81
82
83
84
85
86
# File 'lib/rspec/core/example.rb', line 81

def run_lucian_test
  if Lucian.image.nil? || Lucian.container.nil?
    Lucian.start_lucian_docker
  end
  Lucian.run_lucian_test(self.[:full_description].to_s)
end